Skip to content

Introduction to using Terminal and Display for Segmenting the Hippocampus

Eduardo Garza-Villarreal edited this page Jun 13, 2018 · 3 revisions

Another way to stay connected with integral lab members that you will be in constant contact with or may need help from time to time is to add them as a contact on gmail chat (gchat). The gchat function is on the left side just under your inbox, starred, important etc. list. If you don’t see it there you might need to click “more” at the bottom of that list. You must send an invite to the person first. This can come in useful if you have an urgent question.

Introduction to Neuroanatomy

This is a good website for learning to common nomenclature used in neuroanatomy http://scicurious.scientopia.org/2010/08/24/back-to-basics-2-neuroanatomy-lets-get-started/

There are also some YouTube videos if you are a more visual person https://www.youtube.com/user/DoctorNajeeb https://www.youtube.com/watch?v=BqFN7zTqLDM

There are also some really good apps that you can download that have segmentations right on MRI images Like  https://itunes.apple.com/ca/app/isurf-brainview/id381072423?mt=8 There are a few other ones that you can look up by searching MRI or brain or neuroanatomy in the app store. 

Once you are familiar with the general neuroanatomy, start getting comfortable with the anatomy associated with your specific projects. There are different useful atlases like the Duvernoy hippocampal atlas and the rat brain atlas available at the lab that are super useful! Please ask one of the lab members if you can’t find it.

Relevant Papers to Read


If you are segmenting the hippocampus, these will definitely come in useful. If you’re not, they make for interesting reads!

  1. Winterburn 2013 - This is Julie's paper on segmentation of the human hippocampus at the resolution we are using.  Super valuable. The protocol you will be using to segment the hippocampus

  2. Pruessner 2000 - is a methodology that talks about how to segment out the hippocampus at a whole level.  That is, segmentation of the hippocampus, not of its intricate subfields.

  3. Yushkevich et al. 2014 - This paper talks about subfield harmonization.  There are many different ways groups try to isolate the subregions of the hippocampus, so this is a comparison paper aimed to identify and analyze how they are all different.

  4. Palombo et al. 2013 – Rob and some other people wrote this. It’s about using “segmentation” to evaluate a question of genetics and brain performance. Interesting to read about all the things you can do by segmenting.

Email Vivian/Rob for these four pdfs, they can send them to you via gmail (can’t attach them in word doc).

Introduction to Linux


Once you have read through the tutorials you should be able to access the data through the terminal. Here is the link:

http://www.ee.surrey.ac.uk/Teaching/Unix/

Focus mainly on 1 and 2.

Accessing Data


  1. Open terminal and type cd /data/chamal/projects ls (this command lists everything under the folder you are in)

  2. From there you should see different folders, a folder with your name can be created, this folder will be where you will organize all of your projects.

Some shortcuts used in terminal that might be useful:

  1. To create a folder: Mkdir mkdir “name of your folder” ls to check if the folder you just created is there make sure you make folder under data/chamal/projects/(name of your folder)

  2. Type “xdg-open” to open folder in pop up. This is useful for emailing your labels to another person. To do that you can just open folder in pop up and then drag/drop your file into email.

  3. To rename, type “mv” (name of file you want to rename) (new name of the file)

  4. To move file from a folder type “mv” (source folder name) (target folder name)

  5. To remove files type, “rm” (name of file you want to delete) removing something is permanent. You will not be able to retrieve that file after.

  6. To copy everything under a certain folder type “cp *(all)” (folder address like /data/chamal/projects/Viv)

  7. If you want to copy everything ending in “.mnc” you can use the command: cp *.mnc

  8. To quickly change present folder into another one without going all the way back, a quick short cut is to just type “cd ../viv/” (If you're trying to get into Viv’s folder)

  9. To go all the way back up use “cd ..”

  10. Shell will automatically complete the name of the folder or file if you click “tab”, this way you don’t have to always type the whole name.

  11. To terminate whatever process you have on, type Ctrl C in terminal. This is useful if the mnc file that you’re working on freezes. *Try not to do this very often because if you ctrl c what you're working on, this command does not automatically save your work.

  12. Which leads to a very important point: SUPER IMPORTANT TO BACK UP ALL YOUR FILES and to SAVE AS OFTEN AS YOU CAN !

Opening MINC Tool kit and Display


  1. Opening minc file with labels on from terminal type “Display (name of image) –label (name of label)” Note: It does take a while to load

  2. To save minc file: Go to pop Menu on your minc program keyboard --> click on File --> click on save file .mnc --> go to terminal --> terminal will ask what you want to name your file --> from here you can either 1) save under the same name, terminal will ask if you want to replace the file with the old file with the same name and say yes 2) save under different name -->Save another backup file

  3. Play around with MINC on a random image to get a feel of where everything is, where you can change label colors, saving, erasing etc.

Segmenting


  1. The first thing you will always do once you have your image open and before you start labeling is to set the image in grey scale. You can adjust the exposure in the lime green side bar right beside the sagittal view of your image.

  2. You can do this by clicking on pop menu --> colour coding --> grey scale --> pop menu again to go back to main menu

  3. Once you’ve changed the colour coding, change your brush size: Pop menu --> Segmenting --> change x radius --> open your terminal --> terminal will ask what size --> type in 0.1 --> click enter --> go back to minc and the size should say 0.1

  4. To change the opacity of your label colors: Pop menu --> label opacity --> open terminal --> type 0.3 (or whatever opacity you are comfortable with while labeling) --> click enter --> back to minc file and label opacity should be changed

  5. To zoom in on your image click “ctrl” and hold down scroll button (middle button) on mouse, then you can navigate around the image by holding down “ctrl”.

  6. To move through slices, click and hold the scroll button on the mouse or use the + and - keys. This moves through the slices very quickly.

  7. To erase something, pressing “shift” and right click on the voxels you want to erase.

  8. To quickly change from one label to another without typing into the terminal: You should be In the segmenting part of the keyboard in minc. If you hover over the label of your choice in any section with your cursor and press D- Set paint label, it will automatically change the label. This way is quicker than clicking D – set paint label and then going into terminal to change the colour.

  9. Label in Coronal Sections** and use the other sections to check the boundaries of your labels. To label, hover over any voxel and right click.

  10. To render an anatomical structure 3D (this step is for refining labels): make sure you have the window 3D viewing open. If not type in option -global Hide_3D_window FALSE After typing in Display brain_T2 –label labels.mnc Then pop up menu --> G – create surface --> G- label bin-isosurf --> go to terminal --> the instruction in your terminal will ask you for the maximum and minimum label number. Here you must type in the same number for both maximum and minimum. So if you want to render label 35, the fornix. You must type in 35 and then press enter, then type in 35 again and then enter. --> click back to 3D window, your rendering should be there. To smooth out the edges of your anatomical structure go to --> pop up menu --> E – 3D render --> A – mode wireframe (switch to shaded) OR to smooth --> pop menu --> Z: polygon --> C: smooth polygon

  11. to change the colour of your 3D render go to pop menu --> R- objects --> E- Change Colour --> go to terminal --> type in the colour you'd like (ex. brown, yellow, red etc) --> click back to 3D window and the changed colour should be there.

  12. To 3D render more than one anatomical structure. After completing step 9 or 10, go to --> pop menu --> G- create surface --> B- Make Perm *Make sure to make it permanent before creating another structure. If you don't, the structure you've created will be replaced by a new one.

Important point for 3D rendering: It is important for you to click back to the 3D window before completing another command. It is also very important to have the cursor in your T1/T2 image hovered over the label you want to render in 3D so the computer knows where to start searching for that label. Otherwise, it will take a long time to create the 3D rendering.

Useful tip #1: When labeling, always label the structure by coloring in the border first and click “E - fill” under menu “Segmenting” to fill your bordered structure and it will automatically fill in the structure with the label color. Make sure the border you colored is properly enclose, if one voxel isn’t colored in and you press fill, you may accidentally fill the whole coronal section

Useful tip #2: “7” under the “segmenting” menu is UNDO!!* HOWEVER, this undo button only works for the last action you just did. (It doesn’t work like Microsoft word where you can keep undoing your actions and the previous ones)

Useful tip #3: pop menu  segmenting  hide/show labels is VERY useful when labeling.

**Note that the controls of mnc are all accessible on your keyboard so make sure you always go back to pop menu. Typing “B” under “color coding” is NOT the same as typing “B” under “Segmenting”. So if you click on a control and it’s not doing what you want it to do, don’t “control-C” and terminate everything too hastily, check what menu you’re under, you may be under the wrong one. **

Subfields and White Matter (For Hippocampus)


LEFT Label Number


  1. CA1: 101
  2. CA2/CA3: 105
  3. CA4/Dentate Gyrus: 104
  4. SL/SR/SM: 106
  5. Subiculum: 102
  6. Alveus: 222
  7. Fimbria: 37
  8. Fornix: 33
  9. Mammillary Glands: 12

Right Label Number


  1. CA1: 1
  2. CA2/CA3: 5
  3. CA4/DG: 4
  4. SL/SR/SM: 6
  5. Subiculum: 2
  6. Alveus: 111
  7. Fimbria: 11
  8. Fornix: 35
  9. Mammillary Glands: 22

Useful Tip: It’s easier to colour in the hippocampus as a whole before labeling subfields. When you start labeling subfields, label the body first and then the head (the body is a lot easier to label).

Clone this wiki locally