Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segmentator does not export gradient image when run with the --nogui option #94

Open
torbenelund opened this issue Jun 7, 2023 · 5 comments

Comments

@torbenelund
Copy link

torbenelund commented Jun 7, 2023

Dear Faruk

I have tried to use segmentation to create gradient magnitude images using the command:

segmentator --export_gramag   /Users/lund/Dropbox/LAYNII_test/NIFTI/MP2RAGE_UNI_denoised.nii

which works fine, but when I run it with:

segmentator --export_gramag  --nogui /Users/lund/Dropbox/LAYNII_test/NIFTI/MP2RAGE_UNI_denoised.nii

it instead creates a file which I guess is the 2D histogram in some python format I don't know:

lund@d24512 NIFTI % segmentator --export_gramag  --nogui /Users/lund/Dropbox/LAYNII_test/NIFTI/MP2RAGE_UNI_denoised.nii 
=================
Segmentator 1.6.1
=================
No GUI option is selected. Saving 2D histogram image...
Input image data type is float64.
  Data type is casted to float32.
Scharr gradient method is selected.
  Computing gradients...
  Gradient magnitude computed in: 0 seconds.
  Image saved as:
 /Users/lund/Dropbox/LAYNII_test/NIFTI/MP2RAGE_UNI_denoised_volHist_pcMax97pt5_pcMin2pt5_sc400

Thanks again for your efforts:

Torben

@ofgulban
Copy link
Owner

ofgulban commented Jun 7, 2023

Hi @torbenelund ,

Thanks! Indeed this is the behavior. I have been meaning to renovate this project but ended up not having enough time yet. However, recently, I have implemented a gradient magnitude program in LayNii v 2.4.0 : https://github.com/layerfMRI/LAYNII/releases

See the release comment:

LN2_GRAMAG: Compute gradient magnitude images. Can compute phase image gradient magnitudes correctly when using circular flag. layerfMRI/LAYNII#65

And thanks to this, I have switched to computing the gradient magnitude using LayNii in cases where I am not using the Segmentator GUI. Let me know if this LayNii v2.4.0 pre-release works for you (I am going to add compiled binaries into the pre-release and turn it into a full release soon).

Let me know if this works for you.

@ofgulban
Copy link
Owner

ofgulban commented Jun 7, 2023

I have ended up uploading the compiled LayNii programs now. You can find LN2_GRAMAG within https://github.com/layerfMRI/LAYNII/releases/tag/v2.4.0

@torbenelund
Copy link
Author

Excellent, thanks

@torbenelund
Copy link
Author

torbenelund commented Jun 7, 2023 via email

@ofgulban
Copy link
Owner

ofgulban commented Jun 7, 2023

Interesting. I think by "beta", you refer to the beta parameter used by O’Brien K.R. et al. (2014) Robust T1-Weighted Structural Brain Imaging and Morphometry at 7T Using MP2RAGE. PLoS ONE 9(6): e99676 DOI:10.1371/journal.pone.0099676 , right?

The gradient image should be less affected by bias, whereas the it could be affected by noise (depending on the kernel you use). The magnitude on the other hand is very sensitive to bias (and SNR).

I would agree with this.

It is however clear, that the magnitude gets more smeared with higher beta-values (more bias field).
This statement makes sense to me.

Indeed, the low frequency bias field in the magnitude image is always troublesome for histograms (causes smearing). So it makes sense to me that higher beta leads to stronger bias field which leads to more smeared magnitude x axis.

It does not seem to be the case that gradient image from one beta performs better with magnitude image from another beta.

Gradient magnitude computation with small kernels (e.g. 3x3x3) -in a way- mean-normalize within kernel, so the gradient magnitudes derived from different betas not having much effect on the histograms makes sense to me as well.

Maybe tangentially related, in my experience, the largest difference in the histograms (on decently bial-field removed images) arise after doing high spatial frequency focused filtering on the magnitude images. One example is given at Supp. Fig. 5 from Gulban, O.F., Schneider, M., Marquardt, I., Haast, R.A.M., De Martino, F., 2018. A scalable method to improve gray matter segmentation at ultra high field MRI. PloS one 13, e0198335. https://doi.org/10.1371/journal.pone.0198335

Screenshot 2023-06-07 at 19 45 34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants