layerfMRI / LAYNII

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

Performing Layer Analysis on CA1 Hippocampal Subfield #63

Closed dayanahayek closed 1 year ago

dayanahayek commented 1 year ago

Hi,

I am lately trying to run Layer analysis using LayNii for the Hippocampus, I started with CA1 subfield. What I did is the following: I am using 7T MP2RAGE image resolution iso 0.5 mm.

  1. Draw the borderline / create the rim file (attached) Question 1: How can I make sure I didn't mix up the outer v/s Inner layers?
  2. Use LN_GROW_LAYERS -N21 -rim -ThreeD rim.nii command to generate the layers. Question 2: I used the default 21 layers, but it is only creating 16 layers, is there any explanation for that?
  3. Create the plot (attached) Use the script below:
    
    #!/bin/sh

source ~/.bashrc 3dROIstats -mask rim_leftCA1_layers.nii -1DRformat -quiet -nzmean TrueForm_UNI_images.nii >> layer_t.dat

3dROIstats -mask rim_leftCA1_layers.nii -1DRformat -quiet -sigma TrueForm_UNI_images.nii >> layer_t.dat

3dROIstats -mask rim_leftCA1_layers.nii -1DRformat -quiet -nzvoxels TrueForm_UNI_images.nii >> layer_t.dat

format file to be in columns, so gnuplot can read it.

WRD=$(head -n 1 layer_t.dat|wc -w); for(( i=2;i<=$WRD;i=i+2)); do awk '{print $'$i'}' layer_t.dat| tr '\n' ' ';echo; done > layer.dat

1dplot -sepscl layer.dat mv layer.dat layer_V.dat

gnuplot "gnuplot_layers.txt"


**Question 3: I am not sure how to assess my output (from the plots), is it good or not? can I improve it?**

[rim_leftCA1_layers.nii.zip](https://github.com/layerfMRI/LAYNII/files/10458128/rim_leftCA1_layers.nii.zip)

![TrueForm](https://user-images.githubusercontent.com/123091728/213483720-9b54effe-0e1a-487e-8399-81b9319c7875.jpg)

[rim_leftCA1.nii.zip](https://github.com/layerfMRI/LAYNII/files/10458139/rim_leftCA1.nii.zip)

Thanks a lot for your help!
Dayana
ofgulban commented 1 year ago

Dear @dayanahayek ,

Thanks for considering to use LayNii in your research and spending effort to ask your questions here. I think this issue will be very informative for other people who might be doing similar things.

  1. I would like to stress that LN_GROW_LAYERS is superseded by LN2_LAYERS program since 2020. Therefore if you are doing new analyses, we recommend you to consider using LN2_LAYERS. LN_GROW_LAYERS is still available for backwards compatibility reasons. You might quickly test it with LN2_LAYERS -rim rim_leftCA1.nii.gz -incl_borders command.

  2. The order of inner vs outer layers does not have a meaning other than our convention for the cortical gray matter. For instance, lets say in the first case "inner - outer", the resulting layers will be "1, 2, 3, ... , n" ; if the borders are interchanged to "outer - inner", the resulting layers will be "n, n-1, ..., 3, 2, 1". Therefore as long as you know which side is the starting point of the layers, you can label your figures etc. correctly.

  3. The reason why you are getting 16 layers although requesting 21 is because there are not enough voxels to divide into 21 unique layers in the data. 21 layers suggestion and choice by @layerfMRI applied to cases where the input is around ~0.2 mm isotropic resolution range. You might consider upsampling your data first, if you would like to get 21 separate layers. If you are limited by RAM, you can consider cropping the section around the hippocampus rather than upsampling the whole brain (e.g. see fslroi program from FSL package).

However, I would like to highlight that there is deeper discussion here aside from the practical tips. The new LN2_LAYERS program gives two types of layering outputs: the *layers* file and the *metric* file. Without going into too much detail, the *layers* file is basically a binned version of the *metric* file and might be more useful in your case. Further reading on the details is available at: https://thingsonthings.org/ln2_layers/ , figure 13 might illustrate the point.

If you would prefer to stay with the layers file, I would advise against choosing 21 layers. 3 or maximum 5 would be more appropriate in that case (the ITKSNAP screenshot below shows your 21 layers [on the right] output versus 3 layers output from LN2_LAYERS [on the left]):

Screenshot_2023-01-20_11-20-18

  1. Given above comments, I would be cautious to interpret those 16 layers and maybe first explore the suggestions above before plotting.

Thanks again for your questions. Feel free to follow up or ask further questions anytime, Faruk

dayanahayek commented 1 year ago

Hi Faruk,

Thank you so much for your detailed answer!

I tried the LN2_LAYERS on 3 layers and this is what I got: fig fig_inv

These two graphs are the outputs when I switch the order of the layers: 1- The graph is just symmetrically inverted, does this mean that the numbers I chose for the borderlines are correct? Additional question: can we in the script that generates the plots change the y-axis values? 2- How can I interpret the output, I feel that 3 layers is a low number to interpret based on the plot, what do you think? 3- If I want to try the upsampling, I should crop the hippocampus region from the whole brain image, or simply acquire an MP2RAGE for the Hippocampus region (slab I mean).

Thanks again, looking forward to hear from you Dayana

ofgulban commented 1 year ago

Hi @dayanahayek , I did not have time yet but I will answer your questions soon.

ofgulban commented 1 year ago

Dear @dayanahayek ,

  1. I think maybe I do not fully understand what you are asking by saying "numbers I chose for the borderlines are correct". The first layer and the last layer is completely up to the convention you would like to have. There is no "correct" ordering when computing the depths / layers from a numerical computation point of view. As long as you know e.g. your first layer is closer to white matter and last is closer to csf, it is fine. Which means that you need to indicate this on your x axis, e.g. "Layers (0=white matter)", or "Equi-distant Cortical Depths (1 is white matter)"). You can inspect which layer is closer to which interface by loading and anatomical image and the layers or your rim file in e.g. ITKSNAP. I would also like to highlight that the plotting you are doing is not a part of LayNii. You are using gnuplot plotting program, which is currently lacking the axes titles.

  2. How you can interpret the output is up to you. For me, I would be cautious to put so many layers into a few voxels thick structure if you are going to use the layers file output of LN2_LAYERS. However, if you had e.g. 0.1 mm isotropic resolution, then having more layers would make more sense, in my opinion.

  3. I would recommend acquiring a higher resolution hippocampus image that is optimized for hippocampus coverage at highest possible anatomical resolution if you have this option. However, doing some amount of upsampling even in that case would help. I cannot give very clear directions here as I do not know under which constraints you are conducting your experiments. Maybe a zoom chat would be quicker to understand each other at this point, if you wish to ask further details or clarification.

I have an extra comment that would touch on all of the questions above. You might consider getting familiar with the metric file output of LN2_LAYERS. This metric file gives you voxel-wise depths that are more granular then the layers output (metric file consists of floating point precision cortical depths while layers file consists of integer values). Using the metric file, you can consider plotting your data as a scatter plot, rather than the line plot you are using. I believe, the scatter plot (or when you have too many points a 2D histogram) will be more revealing of your region of interest details. Exemplary region interest based 2D histogram plots can be found at https://doi.org/10.1016/j.neuroimage.2022.119733 Figure 6:

Screenshot_2023-01-30_16-54-15

Hope some of these were helpful. Please don't hesitate to ask further questions.

dayanahayek commented 1 year ago

Hi @ofgulban,

Thanks a lot for your patience and detailed help!

It would be great if we can schedule a meeting because I am also having problems with the upscaling. For now, the data I have is a whole brain 0.5mm image. I will first try with what I have before deciding on the next step.

The scatter plots look great :) I am new to layer analysis so the interpretation is still not 100% clear for me. Let me know when you have time, usually I am available any day between 9-12.

Thanks again and have a great day! Dayana

ofgulban commented 1 year ago

In order to get some pointers, you might consider looking at two scripts I have used to upsample anatomical images in the past :

  1. Cropping a region: https://github.com/ofgulban/meso-MRI/blob/main/scripts/02_MP2RAGE/01_crop.py uses FSL's fsroi program (link here)
  2. Upsampling an anatomical image after cropping: https://github.com/ofgulban/meso-MRI/blob/main/scripts/02_MP2RAGE/02_upsample.py which uses ITKSNAP's c3d program (link to c3d)

I will send you an email to schedule a video call.

ofgulban commented 1 year ago

@dayanahayek , I am closing this issue now as it seems that your initial problems are addressed. Do not hesitate to ask further questions and open new issues in the future.