Resampling a functional image

Dear all,

We are working with some resting state acquisitions in SCT 5.0.1
So far we have managed to normalize them to the PAM50 atlas which produces a massive file of more than 1.4GB. We have been working in some approaches to try and make this file less heavy.

So far our pipeline does the following

  sct_crop_image -i NormalizedResting.nii.gz -zmin 780 -zmax -1 -o NormalizedResting_crop.nii.gz
  fslmaths NormalizedResting_crop.nii.gz -mul 1 NormalizedResting_crop_int.nii.gz -odt int
  sct_resample -i NormalizedResting_crop_int.nii.gz -mm 1x1x3 -o  NormalizedResting_crop_int_2_1x1x3.nii.gz

We find ourselves with a file of 23MB, which is acceptable. Nevertheless, in the last procedure, the resampling, the initial image has 120 volumes; dimensions 141,141,211; voxel size 0,5x0,5x0,5; while the output has 276 volumes; dimensions 70,70,35; voxel size 1x1x3 . Why is that happening? We would expect the output to have also 120 volumes with the corresponding dimensions and voxel size.

And if you also think of another approach to do this, feel free to share it!

Bonus: there is a typo in sct_resample. In the verbose section, flag 2 says expended, should be expanded.

Peace!

aran

Hi @Aran

Thank you for reaching out.

I attempted to reproduce this error using the testing dataset:

sct_download_data -d sct_testing_data
cd sct_testing_data/dmri
sct_resample -i dwi.nii.gz -mm 2x2x2 -o dwi_2mm.nii.gz
sct_image -i dwi.nii.gz -header
# --> dim [4, 40, 42, 5, 6, 1, 1, 1]
sct_image -i dwi_2mm.nii.gz -header
# --> dim [4, 17, 18, 44, 6, 1, 1, 1]

As you can see the output is expected (ie: the 4th dimension (6) is unchanged).

Do you have an example data that you can upload so we can try to reproduce this error?

P.S. Thank you for noting the typo! It will be fixed in the next SCT release.

Good day @jcohenadad,

I was trying your lines with the dmri datatype and obtained the same results as you did.
After that I tried with the fmri datatype and voilà.

sct_download_data -d sct_testing_data
cd sct_testing_data/fmri
sct_resample -i fmri.nii.gz -mm 1x1x3 fmri113.nii.gz
sct_resample -i fmri.nii.gz -mm 2x2x2 fmri222.nii.gz

Unfortunately I cant reproduce the header flag due to my SCT version, I believe.
After checking them manually, original file had 30 volumes and both the resampled ones 34.

Can you check that?

Wow! You found a bug :bug:

I’ve opened a ticket here.

Thank you for reporting this @Aran :pray:

1 Like

Dear @jcohenadad and @joshuacwnewton

I introduced the changes proposed by Joshua here to my resampling.py file and repeated again these small tests

sct_download_data -d sct_testing_data
cd sct_testing_data/fmri
sct_resample -i fmri.nii.gz -mm 1x1x3 fmri113.nii.gz
sct_resample -i fmri.nii.gz -mm 2x2x2 fmri222.nii.gz

The outputs produced had the same timepoints of the inputs so I guess we could mark this problem as solved, pending to be released soon!

Thank you both very much
Peace,

aran

1 Like

Hello! I’m just following up to let you know that this issue has been addressed by the newest version of SCT (v5.5). :tada:

Feel free let us know if you have any further questions or concerns. :slight_smile: