vzachari / IronSmithQSM

Ironsmith is a comprehensive, fully automated pipeline for creating and processing Quantitative Susceptibility Maps (QSM), extracting QSM based iron concentrations from subcortical and cortical brain regions and evaluating the quality of QSM data using SNR measures and assessment of outlier regions on phase images.
Other
18 stars 6 forks source link

MEDI new ref fails #3

Closed bart-larsen closed 2 years ago

bart-larsen commented 2 years ago

Hello,

I am trying to get IronSmith to run on a QSM dataset, but every subject fails at the same point. This is the error message

Creating new CSF/WM reference MEDI analysis file for 21827_11853 --> Subj_21827_11853_MEDI_QSM_New_Ref.m in: /cbica/projects/pennlinc_qsm/output/Ironsmith/21827_11853/QSM

Running MEDI analysis for 21827_11853...

Error: Input folder invalid: MEDI_Output_New_CSF Chris Rorden's dcm2niiX version v1.0.20210317 GCC6.3.0 x86-64 (64-bit Linux)

ESC[31m---------------------------------------------- ERROR: MEDI_QSM_New_Ref.sh FAILED! Skipping 21827_11853... ----------------------------------------------ESC[0m

Nothing gets written in the MEDI_New_Ref_Matlab_Log.txt

If I run the Subj_21827_11853_MEDI_QSM_New_Ref.m code in MATLAB, the error seems to occur at this step: Write_DICOM(Mask_CSF_New_Rot_F3, files, New_CSF_Mask_Dir);

The error it produces is this:

Error using Write_DICOM (line 38) 96 filenames given for 120 slices.

Just to note, the original run of MEDI (e.g. Subj_21827_11853_MEDI_QSM.m) complete successfully.

Any advice is appreciated!

vzachari commented 2 years ago

Hello,

Let's see if we can sort this out. May I have the scanner manufacturer and scanner software version you are using so I can test a few things on my end first?

Thank you,

bart-larsen commented 2 years ago

Great, thank you!

This was acquired on Siemens Prisma. The software version listed in the dicom header is syngo MR E11. Let me know if you need more information.

vzachari commented 2 years ago

OK, I run one participant on my end collected with Syngo MR E11 sequences on the GitHub version of Ironsmith and I could not replicate the bug.

The next step is to try running Ironsmith on data from one of your participants. Is there any way you could share the necessary files for one of your participants? The exact input files that cause the error on your end.

bart-larsen commented 2 years ago

Is there a way I can contact you to share some data privately. I do not want to post dicom files as they may contain PHI. Let me know what works for you!

vzachari commented 2 years ago

Yes, of course. Here is my e-mail: vzachari "AT" uky.edu Would a google drive or OneDrive link with zipped compressed DICOMs from one participant work?

vzachari commented 2 years ago

Greetings,

I was able to replicate the issue using the data you provided. The error occurs in IronSmithQSM/Functions/MEDI_QSM_New_Ref.sh and is related to the code on lines 117-125

` echo "Mask_CSF_New_Rot = permute(Mask_CSFNew,[2,3,1]);" >> Subj${Subj}_MEDI_QSM_New_Ref.m echo "Mask_CSF_New_Rot_F1 = flip(Mask_CSF_NewRot,1);" >> Subj${Subj}_MEDI_QSM_New_Ref.m echo "Mask_CSF_New_Rot_F2 = flip(Mask_CSF_New_RotF1,2);" >> Subj${Subj}_MEDI_QSM_New_Ref.m echo "Mask_CSF_New_Rot_F3 = flip(Mask_CSF_New_RotF2,3);" >> Subj${Subj}_MEDI_QSM_New_Ref.m

echo "Mask_WM_New_Rot = permute(Mask_WMNew,[2,3,1]);" >> Subj${Subj}_MEDI_QSM_New_Ref.m echo "Mask_WM_New_Rot_F1 = flip(Mask_WM_NewRot,1);" >> Subj${Subj}_MEDI_QSM_New_Ref.m echo "Mask_WM_New_Rot_F2 = flip(Mask_WM_New_RotF1,2);" >> Subj${Subj}_MEDI_QSM_New_Ref.m echo "Mask_WM_New_Rot_F3 = flip(Mask_WM_New_RotF2,3);" >> Subj${Subj}_MEDI_QSM_New_Ref.m `

It would appear the transformation needed to align/register the Freesurfer lateral ventricle mask to MEDI space in MATLAB is different for your data than for all the data I used to test Ironsmith.

I adjusted the code to fit your data and as long as your T1 and QSM scans are from the same scanner, using the same sequences, the new transformation I applied will work.

I also updated which lateral ventricles mask Ironsmith will use as the QSM reference (CSF reference). For your data, I would use the ${Subj}_freesurfer_LR_Lateral_Ventricle_Mask_AL_QSM_RS_Erx1.nii.gz instead of ${Subj}_freesurfer_LR_Lateral_Ventricle_Mask_AL_QSM_RS_Erx2.nii.gz

Please rename your current IronSmithQSM/Functions/MEDI_QSM_New_Ref.sh file to MEDI_QSM_New_Ref_OLD.sh download the attached MEDI_QSM_New_Ref.zip file, unzip it and place the resulting .sh file in IronSmithQSM/Functions/

Test with one or two participants and let me know how it goes. The participant you provided works on my end, following the updates to MEDI_QSM_New_Ref.sh

MEDI_QSM_New_Ref.zip

I will update Ironsmith in the near future to automatically figure out this transformation so no one has to deal with this bug again.

bart-larsen commented 2 years ago

Wonderful! I will test this today and confirm it is successful. Thanks!

bart-larsen commented 2 years ago

It seems to be successfully completing for all the subjects. Looks like the fix worked. Thank you!

vzachari commented 2 years ago

Thank you for identifying this bug. I have updated Ironsmith to V1.3 Beta which should fix this issue.