davidssmith / DCEMRI.jl

DCE MRI analysis in Julia
Other
37 stars 16 forks source link

Data format #15

Closed elijahrockers closed 8 years ago

elijahrockers commented 8 years ago

I see in the README that the data is required to be a 3D matrix, 1 time and 2 space...

Is there any possibility of using 4D matrices, i.e., a time series of volumes?

davidssmith commented 8 years ago

I think the README may be inaccurate. I think I adapted the code to work with any number of dimensions, as long as the first is time. Try it and see.

If it doesn't work already, it should be possible with minor modifications.

elijahrockers commented 8 years ago

Ok. While we're on the topic of data format however, before I can try it I'm wondering how to get my data into .mat format. I have images in .nii format, and I have a tool to load .nii into matlab as structs.

Per the readme:

The input data MAT file must contain the following:

    Cp: Arterial input function as a vector, resampled to the DCE time points.
    DCEdata: DCE data as a 3-D array (1 time by 2 space dimensions).
    DCEflip : flip angle in deg of DCE data
    t: time vector representing the dcedata samples.
    TR: repetition time of DCE scan
    R1 information as either R10 and S0, representing pre-calculated R1 relaxation maps, or as T1data, indicating that a multi-flip scan was performed and must be analyzed. If T1data is supplied, the code also needs T1flip, a vector of flip angles (in degrees) for the multi-flip data.

Is this a matlab struct with those elements? I would try to glean this info from the code but I'm not 100% sure where to look for answers

davidssmith commented 8 years ago

No struct necessary. Just use these names for the variables, and then save them into a .mat file within Matlab. The command would look something like

save input.mat Cp DCEdata DCEflip t TR R1
elijahrockers commented 8 years ago

Ah ok. Simpler than I was making it. I will try it and see about the dimensionality

elijahrockers commented 8 years ago

Assertion error: length(t1flip) == size(t1data,1)

I am assuming this is because the code is expecting the 1st dimension to be flip angle, instead of a spatial dimension.

My t1 maps are also 3D volumes, and to concatenate them into a single variable in MATLAB I used the 4th dimension, given that the first 3 dimensions are spatial.

My DCE data is also 4 dimensional, with the fourth dimension being time.

Am I correct in assuming the code assumes the first dimension is 'time/flip angle'? I could swap around my dimensions, but that is severe pain in the ass and opens up the potential for errors. Another option could be to code in a check for 2 or 3 dimensional data, or maybe specify which dimension is time/flip angle?

davidssmith commented 8 years ago

Yes, the code assumes that time or flip angle is in the first dimension. I could make the code general, but it will slow it down quite a bit. The first dimension is contiguous in RAM, and doing least squares fitting in time or flip angle is much faster if the points being fitted are able to be fetched with a single load operation. Even in Matlab you will do better having time as dimension 1.

You can prepare the data by using shiftdim in Matlab. For 3D data, where time is in the last dimension,

data_shifted = shiftdim(data,2);

To undo the shift,

data = shiftdim(data_shifted,1);
elijahrockers commented 8 years ago

The first dimension is contiguous in RAM

I did not know that.