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

Ironsmith stops at MEDI_QSM_New_Ref.sh step as of a MATLAB error #7

Closed johntrevorivano closed 1 year ago

johntrevorivano commented 1 year ago

Hello, I'd like to begin with huge Thanks for all efforts up to date, and for any coming help.

Starting from the Ironsmith version featuring the new way of aligning the freesurfer ventricles mask to the QSM data (Mask_xx_New_Perm_Tran instead of the old Mask_xx_New_Rot..), current script always halts at step: "Creating new CSF/WM reference MEDI analysis file for [...] "

I see that RDF.mat is correctly renamed to RDF.mat.QSM.Script just a moment before the error, thus bringing to the conclusion that the issue is related to MATLAB execution of Subj_$Subj_MEDI_QSM_New_Ref.m .

System used: Ubuntu 20.04 with MATLAB r2018b, Ironsmith 1.4 beta (error occurred also with 1.3beta).

executing Subj_$Subj_MEDI_QSM_New_Ref.m on windowed Matlab for debugging purposes, gave these errors (I'm using reference lines of the corresponding MEDI_QSN_New_Ref.sh )

227 - echo "MatOrder(2)=find(abs(Affine3DR2)>0.98 & abs(Affine3DR2)<=1);" >> Subj_${Subj}_MEDI_QSM_NewRef.m 228 - echo "MatOrder(3)=find(abs(Affine3DR3)>0.98 & abs(Affine3DR3)<=1);" >> Subj${Subj}_MEDI_QSM_New_Ref.m

obviously resulted in these lines on Subj_$Subj_MEDI_QSM_New_Ref.m:

27 - MatOrder(2)=find(abs(Affine3DR2)>0.98 & abs(Affine3DR2)<=1); 28 - MatOrder(3)=find(abs(Affine3DR3)>0.98 & abs(Affine3DR3)<=1);

On both commands the output was: Unable to perform assignment because the left and right sides have a different number of elements.


Please note that first assignment MatOrder(1)=find(abs(Affine3DR1)>0.98 & abs(Affine3DR1)<=1); gave no errors.

Again with many thanks, I ask you to let us know if logfiles, scripts or original dicoms are needed for you to help somehow. Best Regards Ivano Chiarotti

vzachari commented 1 year ago

Greetings,

Give me a few days and I'll look into it,

Thank you,

vzachari commented 1 year ago

Greetings,

Apologies for the long delay. I was interviewing for faculty positions. If you can provide DICOMs from one participant that is causing this issue, I can try to debug on my end. I will need the GRE Magnitude/Phase DICOMs and corresponding T1-weighted DICOMs (MPRAGE) or the MPRAGE can be a single nii file. You can e-mail me at vzachari @ uky.edu

Thank you,

vzachari commented 1 year ago

The issue might be related to abs(Affine3DR2) and abs(Affine3DR3) being slightly less than 0.98. Could you check the values in abs(Affine3DR2) and abs(Affine3DR3) in Matlab?

johntrevorivano commented 1 year ago

Dear Professor Zachari,

I have gone through more debugging, based on your kind suggestion. This has required some time to reply, please excuse me.

Firstly, I've made data available for you to debug on your side. Just emailed you two gdrive links with QSM and MPRAGE data files. The choosen case is representative of any case studied.

As for the value of abs(Affine3Dr2[/3]), I can confirm that values seem to be between 0.93 and 0.94: could you please check on DICOM tags on provided dataset? Following this observation, I changed the script (MEDI_New_Ref) from :

[original] MatOrder(2)=find(abs(Affine3DR2)>0.98 & abs(Affine3DR2)<=1); to: [modified] MatOrder(2)=find(abs(Affine3DR2)>0.93 & abs(Affine3DR2)<=1); (also applies to 3rd MatOrder).

With these modifications, script correctly run until completion.

Is any tweaking to Mri acquisition parameters advisabile, based on your experience?

vzachari commented 1 year ago

Hello,

Running Ironsmith on my end now with the data you provided. I'll let you know what I find,

Thank you

vzachari commented 1 year ago

Hello,

I run the MRI data you provided and the QSM maps look good. I think your scan parameters are fine. I would recommend updating MEDI.sh and MEDI_QSM_New_Ref.sh under IronSmithQSM/Functions with the ones provided in the attached zip file.

CustomMEDI.zip

Ironsmith had some issues with the QSM scan being collected at an angle (the GRE scans of your project are oblique). The updates I made will ensure your data is processed correctly.

Maybe keep the old MEDI.sh and MEDI_QSM_New_Ref.sh files in case they are needed, so just rename them MEDI_OLD.sh and MEDI_QSM_New_Ref_OLD.sh and then copy the attached files over in IronSmithQSM/Functions.

Let me know how it goes,

Thank you,

johntrevorivano commented 1 year ago

Dear Professor Zachariou,

We'd like to thank you for patience, time and efforts employed for this cause. Ironsmith operations went smoothly using those custom modified scripts. It seems that a more tollerant cut-off value is needed during automated searching for patient's orientation (abs value of about 0.93 on our MRI GRE data, tough original cut-off did not allow values less than 0.98 to proceed). We also took note of other modifications you have made to the transformation/deoblique sections of the scripts.

At our Neuroradiology Unit we expect to explore possibilities provided by your automated Tool, and to give your work more credits in the near future!

Best Regards, Ivano Chiarotti

vzachari commented 1 year ago

Thank you. Happy to help!