I am trying to run 3dfim+ to calculate a correlation map for a region of interest. I de-obliqued the data (the functional and the ROI mask which was converted to the same functional space) with 3drefit -deoblique (because I was getting an error message about data being oblique). However the de-obliqued functional image now doesn't have the time dimension and the 1D file I'm getting when extracting timeseries from a ROI mask applied to this functional only has one number in it (884.727 [264 voxels]). Isn't it supposed to be a column of averaged voxel intensities in this ROI for each time point? Where did all the volumes go? When I try to run 3dfim+ I receive the following error:
Matrix error: Incompatible dimensions for vector multiplication: 0x0 X 1 ** Memory usage: chunks=84 bytes=621942 Standard error: ++ 3dfim+: AFNI version=AFNI_2011_05_26_1457 (Jun 22 2011) [64-bit] ++ Authored by: B. Douglas Ward 3dfim+ main Return code: 1 Interface Fim failed to run.
The command I try to run is
3dfim+ -input /path/mcorr_001_brain_3drefit.nii.gz -ideal_file /path/mcorr_001_brain_3drefit_maskave.1D -out Correlation -bucket corr_map.nii.gz
I tried to run the same but with the original oblique data and additional to the standard:
"WARNING: If you are performing spatial transformations on an oblique dset, such as /path/roi_sphere_30_21_18_flirt.nii.gz,or viewing/combining it with volumes of differing obliquity, you should consider running: 3dWarp -deoblique on this and other oblique datasets in the same session. "
There is still the error of "Matrix error: Incompatible dimensions for vector multiplication: 0x0 X 1" so it doesn't seem that deobliquing caused this problem!
Does anyone have any idea what might cause this problem?
check your input file (mcorr_001_brain_3drefit.nii.gz) with 3dinfo to see if it has a time axis (TR information). If not simply add a time axis with 3drefit.
Related
I have train my LSTM network and deploy it on the Arduino but my problem is that as you know the input of the LSTM network is as follows (window length of the time series data),(features) in my case 256 window length and 6 axis IMU data which means 2D input however all of the examples that I have seen are only 1D input
here is the Arduino code that used to assign the model's input
input->data.f[0] =aX
and when trying to modify the code to fit my input dimension
(256,6) like this
input->data.f[0][0] =aX
I got this error
fall_detection:142:44: error: invalid types 'float[int]' for array subscript
tflInputTensor->data.f[samplesRead][5] = (gZ + 2000.0) / 4000.0;
It looks like you are setting the tensor input data "manually" by digging in to the internal structure of the TF Lite tensor type. I would suggest using the API here:
https://www.tensorflow.org/lite/guide/inference#load_and_run_a_model_in_c
In particular the code snippet here:
float* input = interpreter->typed_input_tensor<float>(0);
// Fill `input`.
gives you the proper pointer. Then you can just cast the pointer for your actual data structure. Something like this:
input = reinterpret_cast<float *>(aX);
I see the potential for confusion for the 2D vs. 1D issue, but it is OK as long as the input tensor is properly shaped. If it has shape <256, 6> what this means is that the 1D sequence of float values will be "a0,a1,a2,a3,a4,a5,b0,b1,..." where the "a" values are all six values of the first row, the "b" values are all six values of the next row and so on. The standard C convention for multi-dimension memory layout works this way. Unless there is something unusual about your aX object, it should be fine. If aX is not laid out in this fashion, you should copy the data so that it is in this layout.
I have been modelling and simulating a number of simple district heating networks in Dymola and am quite often faced with an error during initialisation.
The system we are simulating consists of
A producer: two pressure boundaries - source and sink. Pressure at source is controlled via PI which ensures that the source pressure is such that the minimum differential pressure accross a consumer is greater than or equal to some set value.
Consumers: They have a PI controlled valve and a heat exchanger with a fixed return temp. Valve controls mass flow and subsequently the heat flow to match the consumer load at any given time.
Pipes: dynamic thermo-hydraulic model with heat loss and and Spatialdistribution to account for delay. Vectorised ports and mixing volumes used to reduce non linear equations.
The figure below is a heavily simplified version of the network (same error occuring here)
The consumer model looks as follows:
And the producer:
During initialisation, the following error occurs:
ERROR: Failed to solve non-linear system using Newton solver.
To get more information: Turn on Simulation/Setup/Debug/Nonlinear solver diagnostics/Details
Solution to systems of equations not found at time = 0
Nonlinear system of equations number = 3
Infinity-norm of residue = 118280
Iteration is not making good progress.
Accumulated number of residue calc.: 389
Accumulated number of symbolic Jacobian calc.: 5
Last values of solution vector:
L.PI.gainPID.y = 0
Last values of residual vector:
{ -118280 }
Trying to solve non-linear system using global homotopy-method.
... loading "data" from "C:/Users/Sim1/Desktop/Keith Dymola Files/GrazReininghaus_UseCase/PythonScriptsforTranslation/Reininghaus.txt"
ERROR: Failed to solve non-linear system using Newton solver.
To get more information: Turn on Simulation/Setup/Debug/Nonlinear solver diagnostics/Details
Solution to systems of equations not found at time = 0
Nonlinear system of equations number = 1
Infinity-norm of residue = 2.22814E+018
Iteration is not making good progress.
Accumulated number of residue calc.: 101
Accumulated number of symbolic Jacobian calc.: 9
Last values of solution vector:
M.port_a.m_flow = 0.000485868
N.valveLinear.dp = -55.8243
O.valveLinear.dp = -135.618
P.valveLinear.dp = 550.474
I.port_a.m_flow = 3.20321E-010
C.port_a.m_flow = 2.19343E-011
D.port_a.m_flow = 0.00208272
E.valveLinear.dp = 371.552
L.port_a.m_flow = -7.10982E-012
J.valveLinear.dp = 243.085
K.port_a.m_flow = 1.924E-005
Last values of residual vector:
{ 6.60393E+013, -1.14781E+018, -1.05438E+018, -2.58754E+016, -111988,
-1.56817E+010, 16024.9, 3.14411E+007, 3.99781E+008, 3.14412E+007,
-15012.9 }
Error: could not solve simplified initialization for homotopy method.
Error: could not solve simplified initialization for homotopy method.
FixInitials:Init
The components A,B,C e.t.c are the consumers in the network. I am using the Radau IIa 5th order solver with tol=1e-06. The PI controller in the consumer valves inittype is to integrate only with integrtor state and the PI in the producer is initialised with an output value.
I have tried playing around with all sorts of nominal values for mass flows and pressure drops in the network, a well as initial values in the PI controllerrs but the same form ERROR is always returned. The model passes the error check but always fails at initialisation.
I would like to know if anybody has had experience in debugging such nonlinear systems, and if so, a few tips in how to initialise these models would be a great help with the debugging process.
Ok so for anybody who is interested, I managed to simulate my network in the end. It turns out the initialisation problem was arising in the "first order" block within the consumer which takes the measured heat flow signal in the heat exchanger and passes it to the PI. The default init type for this component was "noinit", however by changing it to take in an initial guess value (nominal consumer load worked in this case), the initialisation sections passed. I guess this problem occured in this example as my consumer nominal loads were quite a bit higher than in previous examples and therefore the initial value was outside of the suitable range without specifying it manually.
In my program, I need to have a function, that makes continuous density estimate (defined everywhere on reals) from arbitrary sample. So I've chosen the library(ks) and found that it sometimes produces buggy object, and other functions (e.g. plot) crash R session while accessing it.
Please, I want someone else to check whether it is a bug in the package, my R build, (or even I'm doing something wrong).
So, the code to reproduce the crash :
library(ks)
set.seed(8192)
density_generator<-function(s)
{
# this function returns kernel density estimate built on sample 's'
hpi1 <- hpi(x=s) # calculating h parameter for kernel estimation
fhat.pi1 <- kde(x=s, H=hpi1) # generating density object
fhat.pi1
}
## testing the density generator
conditional_density_object<-density_generator(c(1,2,3,4,5))
foo<-function(z){predict(conditional_density_object,x=z)}
y<-seq(from=-7,to=11, by=0.01) # R session fails for some of the parameters
plot(y,sapply(y,foo),pch=".")
Other parameters, e.g. y<-seq(from=-7,to=5, by=0.01) do not crash the R session:
If everything works Ok for the range (-7,11) - please, check other (large) numbers, maybe this is system-specific.
I'm trying to use the Isomap algorithm from the ManifoldLearning.jl package (https://github.com/wildart/ManifoldLearning.jl). However, following the usage example provided in the docs (http://manifoldlearningjl.readthedocs.org/en/latest/isomap.html), throws the below error:
ERROR: LoadError: ArgumentError: collection must be non-empty
in extrema at reduce.jl:337
in classical_mds at /Users/rprechelt/.julia/v0.4/MultivariateStats/src/cmds.jl:75
in transform at /Users/rprechelt/.julia/v0.4/ManifoldLearning/src/isomap.jl:75
in isomap at /Users/rprechelt/code/julia/subwoofer.jl:198
where line 198 is transform(Isomap, X; k=12, d=2) where X is a non-empty (verified using isempty) array where each column is a data sample.
I've tried to trace the error back from reduce.jl but I can't seem to locate where collection is becoming non-empty. The same array (X) works perfectly with LTSA, and other algorithms from the ManifoldLearning.jl package, just not Isomap.
Has anyone encountered this before? Any recommendations?
Isomap invokes classical multidimensional scaling on geodesic distance matrix constructed from an original data. Commonly, MDS algorithm performs an spectral decomposition to find a proper embedding. From the above error, it looks that the decomposition returns an empty spectrum of a geodesic distance matrix. In any case, it is better to open an error issue with the package project on GitHub for a further investigation.
One thing that sometimes happens is that if your points are, for example, exactly on a line, then a matrix created by MDS is rank 1, and depending on the implementation, this may cause errors if you are searching for an Isomap embedding of more than 1 direction.
Dirty hack fix: add a small amount of random noise to all your input points (i think to all the elements of your array X).
I am currently learning Modelica by trying some very simple examples. I have defined a connector Incompressible for an incompressible fluid like this:
connector Incompressible
flow Modelica.SIunits.VolumeFlowRate V_dot;
Modelica.SIunits.SpecificEnthalpy h;
Modelica.SIunits.Pressure p;
end Incompressible;
I now wish to define a mass or volume flow source:
model Source_incompressible
parameter Modelica.SIunits.VolumeFlowRate V_dot;
parameter Modelica.SIunits.Temperature T;
parameter Modelica.SIunits.Pressure p;
Incompressible outlet;
equation
outlet.V_dot = V_dot;
outlet.h = enthalpyWaterIncompressible(T); // quick'n'dirty enthalpy function
outlet.p = p;
end Source_incompressible;
However, when checking Source_incompressible, I get this:
The problem is structurally singular for the element type Real.
The number of scalar Real unknown elements are 3.
The number of scalar Real equation elements are 4.
I am at a loss here. Clearly, there are three equations in the model - where does the fourth equation come from?
Thanks a lot for any insight.
Dominic,
There are a couple of issues going on here. As Martin points out, the connector is unbalanced (you don't have matching "through" and "across" pairs in that connector). For fluid systems, this is acceptable. However, intensive fluid properties (e.g., enthalpy) have to be marked as so-called "stream" variables.
This topic is, admittedly, pretty complicated. I'm planning on adding an advanced chapter to my online Modelica book on this topic but I haven't had the time yet. In the meantime, I would suggest you have a look at the Modelica.Fluid library and/or this presentation by one of its authors, Francesco Casella.
That connector is not a physical connector. You need one flow variable for each potential variable. This is the OpenModelica error message if it helps a little:
Warning: Connector .Incompressible is not balanced: The number of potential variables (2) is not equal to the number of flow variables (1).
Error: Too many equations, over-determined system. The model has 4 equation(s) and 3 variable(s).
Error: Internal error Found Equation without time dependent variables outlet.V_dot = V_dot
This is because the unconnected connector will generate one equation for the flow:
outlet.V_dot = 0.0;
This means outlet.V_dot is replaced in:
outlet.V_dot = V_dot;
And you get:
0.0 = V_dot;
But V_dot is a parameter and can not be assigned to in an equation section (needs an initial equation if the parameter has fixed=false, or a binding equation in the default case).