layerfMRI / LAYNII

Stand alone fMRI software suite for layer-fMRI analyses.
BSD 3-Clause "New" or "Revised" License
85 stars 26 forks source link

LN2_LAYERS - empty equivol files #55

Closed ravenep closed 2 years ago

ravenep commented 2 years ago

Hello!

I have a small issue on basic usage I was hoping to get your help on. I start here to generate 3d whole brain rimified data. The data are macaque, and have been upsampled to 0.25 isotropic voxel size.

LN2_RIMIFY -input pve_classify.nii -innergm 3 -outergm 1 -gm 2 -output rim.nii

Screen Shot 2022-06-15 at 11 41 17 AM

I then try LN2_LAYERS. It generates the midGM, but does not seem to make the layers themselves. The files are made but empty. Do you have some idea of what I might be doing wrong here?

LN2_LAYERS -rim rim.nii -nr_layers 20 -equivol -iter_smooth 100

Screen Shot 2022-06-15 at 11 39 27 AM

Thanks for any insight!

ofgulban commented 2 years ago

Hi @ravenep ,

that seems strange, can you post the full list of the outputs generated by LN2_LAYERS, maybe together with the terminal output?

ofgulban commented 2 years ago

Can you check if the min max range of fsleyes is adjusted properly? Maybe they just look empty because min max are the same number in fsleyes. I saw this behavior before

ravenep commented 2 years ago

Thanks for your message. I did check in a few different viewers with different scalings (mrtrix, fsleyes, wbview) but no luck. Happy to share a data set if that is easier. I also tried the original LN_GROW_LAYERS and got a segmentation fault.. maybe it is something lurking under the surface. Just weird that midGM is working?!

output files

rim_layers_equidist.nii rim_layers_equivol.nii rim_metric_equidist.nii rim_metric_equivol.nii rim_midGM_equidist.nii rim_midGM_equivol.nii

here is the terminal output

LN2_LAYERS -rim rim.nii -nr_layers 20 -equivol -iter_smooth 100
=======================
LAYNII v2.2.1dev          
=======================
LN2_LAYERS

    File name: rim.nii
    Image details: 421 X | 430 Y | 255 Z | 0 T 
    Voxel size = 0.25 x 0.25 x 0.25
    Datatype = 4

  Nr. layers: 20
  Rim file voxel sparsity 0%

  Start growing from inner GM (WM-facing border)...

  Start growing from outer GM...

  Start layering (equi-distant)...

  Start mildly smoothing equidistant cortical depths...

  Saving equidistant metric and layers files...
    Writing output as:
      rim_metric_equidist.nii
    Writing output as:
      rim_layers_equidist.nii

  Start finding middle gray matter (equi-distant)...
    Writing output as:
      rim_midGM_equidist.nii

  Start equi-volume stage...

  Start computing equi-volume factors...

  Start smoothing equi-volume transitions...

  Start final layering...
    Writing output as:
      rim_layers_equivol.nii

  Start mildly smoothing equivolume cortical depth...

  Saving equivolume metric and layers files...
    Writing output as:
      rim_metric_equivol.nii
    Writing output as:
      rim_layers_equivol.nii

  Start finding middle gray matter (equi-volume)...
    Writing output as:
      rim_midGM_equivol.nii
ofgulban commented 2 years ago

Hmm, then maybe send me your rim file and I can quickly check. I recommend using LN2_LAYERS, older programs are there for backwards compatibility

ravenep commented 2 years ago

Ok, thanks, I will send it now. LN2_LAYERS is definitely my preference. I wasn't sure if we could learn something using the old code.

ravenep commented 2 years ago

Just realized I can paste a link, here it is, https://drive.google.com/drive/folders/1avaTRcbTmnpaFFuhLwK-dFlQna2uh1RR?usp=sharing

ofgulban commented 2 years ago

Thanks!, It seems that this is a nifti header issue. Ok, here we go:

  1. Your rim file header from fslhd:
    
    filename    /home/faruk/Documents/temp-erika_laynii/rim.nii.gz

sizeof_hdr 348 data_type INT16 dim0 3 dim1 421 dim2 430 dim3 255 dim4 0 dim5 0 dim6 0 dim7 0 vox_units mm time_units Unknown datatype 4 nbyper 2 bitpix 16 pixdim0 1.000000 pixdim1 0.250000 pixdim2 0.250000 pixdim3 0.250000 pixdim4 0.000000 pixdim5 0.000000 pixdim6 0.000000 pixdim7 0.000000 vox_offset 352 cal_max 0.000000 cal_min 0.000000 scl_slope 0.000000 scl_inter 0.000000 phase_dim 0 freq_dim 0 slice_dim 0 slice_name Unknown slice_code 0 slice_start 0 slice_end 0 slice_duration 0.000000 toffset 0.000000 intent Unknown intent_code 0 intent_name intent_p1 0.000000 intent_p2 0.000000 intent_p3 0.000000 qform_name Unknown qform_code 0 qto_xyz:1 0.250000 0.000000 0.000000 0.000000 qto_xyz:2 0.000000 0.250000 0.000000 0.000000 qto_xyz:3 0.000000 0.000000 0.250000 0.000000 qto_xyz:4 0.000000 0.000000 0.000000 1.000000 qform_xorient Left-to-Right qform_yorient Posterior-to-Anterior qform_zorient Inferior-to-Superior sform_name Unknown sform_code 1 sto_xyz:1 0.250000 0.000000 0.000000 -52.500000 sto_xyz:2 0.000000 0.250000 0.000000 -61.500000 sto_xyz:3 0.000000 0.000000 0.250000 -26.750000 sto_xyz:4 0.000000 0.000000 0.000000 1.000000 sform_xorient Left-to-Right sform_yorient Posterior-to-Anterior sform_zorient Inferior-to-Superior file_type NIFTI-1+ file_code 1 descrip mnc2nii 41759_pve_classify.mnc 41759_pve_classify.nii aux_file


2. I have quickly load this rim file in ITKSNAP as segmentation file and saved as `rim_savedbyitksnap.nii.gz`. This gives:

filename /home/faruk/Documents/temp-erika_laynii/rim_savedbyitksnap.nii.gz

sizeof_hdr 348 data_type UINT16 dim0 3 dim1 421 dim2 430 dim3 255 dim4 1 dim5 1 dim6 1 dim7 1 vox_units mm time_units Unknown datatype 512 nbyper 2 bitpix 16 pixdim0 1.000000 pixdim1 0.250000 pixdim2 0.250000 pixdim3 0.250000 pixdim4 0.000000 pixdim5 0.000000 pixdim6 0.000000 pixdim7 0.000000 vox_offset 352 cal_max 0.000000 cal_min 0.000000 scl_slope 1.000000 scl_inter 0.000000 phase_dim 0 freq_dim 0 slice_dim 0 slice_name Unknown slice_code 0 slice_start 0 slice_end 0 slice_duration 0.000000 toffset 0.000000 intent Unknown intent_code 0 intent_name intent_p1 0.000000 intent_p2 0.000000 intent_p3 0.000000 qform_name Scanner Anat qform_code 1 qto_xyz:1 0.250000 0.000000 0.000000 -52.500000 qto_xyz:2 0.000000 0.250000 0.000000 -61.500000 qto_xyz:3 0.000000 0.000000 0.250000 -26.750000 qto_xyz:4 0.000000 0.000000 0.000000 1.000000 qform_xorient Left-to-Right qform_yorient Posterior-to-Anterior qform_zorient Inferior-to-Superior sform_name Scanner Anat sform_code 0 sto_xyz:1 0.000000 0.000000 0.000000 0.000000 sto_xyz:2 0.000000 0.000000 0.000000 0.000000 sto_xyz:3 0.000000 0.000000 0.000000 0.000000 sto_xyz:4 0.000000 0.000000 0.000000 1.000000 sform_xorient Unknown sform_yorient Unknown sform_zorient Unknown file_type NIFTI-1+ file_code 1 descrip
aux_file



3. Running `LN2_LAYERS` on this file gives the expected nifti visualizations:
`metric file`
![Screenshot from 2022-06-15 19-22-44](https://user-images.githubusercontent.com/4668327/173888441-98cb9f10-a62d-4d48-b24b-7507a7921405.png)
`layers file`
![Screenshot from 2022-06-15 19-22-52](https://user-images.githubusercontent.com/4668327/173888449-31660735-6a40-4377-a348-4526d54d90ca.png)

4. So my conclusion is that, this is a visualization software nifti header problem. The voxel data is computed and written correctly, only that the visualization software are not displaying them because of the header interpretation issues. I don.t have too much time to have a deep look into this until after 26 June, but maybe the above workaround will give you what your want. By the way, I recommend you to consider the metric file rather than 20 discrete layers, but you decide :) .
ravenep commented 2 years ago

thanks for that insight, I would not have checked that detail. This is a very useful workaround, and solves my problem :)