BIC-MNI / minc-tools

Basic minc-tools from former minc repository
Other
29 stars 25 forks source link

add_philips_info temporal id determination #73

Open jpcoutu opened 6 years ago

jpcoutu commented 6 years ago

I encountered an issue with Philips diffusion dicom files that did not get converted properly. The cause was this line in the add_philips_info sub in dicom_to_minc.c:

int id = (i1 < c1) ? i1 : (c1 + i2);

In this context, i1 is the b-value index of the file (varies between 1 and c1, which is the total number of different b-values), i2 is the gradient orientation index and c2 is the gradient orientation count (which I think stores the highest gradient orientation index rather than the actual count), which are defined in pms_elements_defs.h.

My dicom files have a c1 of 3 and c2 of 66. The first dicom had (i1 = 1, i2 = 66), followed by 64 dicoms with (i1 = 2, i2 between 2 and 65) and then 4 dicoms with (i1 = 3, i2 between 2 and 66). This repeats for every slice location. The corresponding b-values for i1 =1, 2 ,3 were 0, 1000 and 0 (technically 0.001, which is why it got a different i1 number). This scheme did not really work with the line above, which seems to assume that only the last i1 value / b-value has gradient orientations. I changed it to this line:

int id = (i1 - 1) * c2 + i2;

which makes sure to attribute a unique id for a given b-value and gradient orientation index. This doesn't necessarily create contiguous temporal position ids, but I think sort_dimensions() takes care of that. It seems to have fixed my problem, so I figured I should post this fix here. Only side effect I can see seems to be that a bogus start and step gets attributed to the time dimension, but those don't really mean anything for diffusion. However I do not have much other Philips diffusion data to test this on.

jpcoutu commented 3 years ago

This is fixed in https://github.com/BIC-MNI/minc-tools/pull/113