Skip to content

Commit

Permalink
added workshop 6 and re-organised workshop 5
Browse files Browse the repository at this point in the history
  • Loading branch information
sohaamir committed Jan 6, 2025
1 parent baf61d8 commit ad71b82
Show file tree
Hide file tree
Showing 30 changed files with 426 additions and 79 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/workshop6/edit_scripts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/workshop6/scripts_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 17 additions & 14 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,34 @@ This website contains workshop materials created for the MSc module 'Magnetic Re
</p>

<h3>Dr Magdalena Chechlacz</h3>
<b>Role: Course Lead</b>
<b style="display: block; margin-bottom: 20px;">Role: Course Lead</b>
<div class="social-links" style="display: flex; flex-direction: row; gap: 5px; justify-content: flex-start;">
<div class="social-item"><a href="mailto:m.chechlacz@bham.ac.uk"><i class="fa-solid fa-envelope fa-xl"></i></a></div>
<div class="social-item"><a href="https://orcid.org/0000-0003-1811-3946" target="_blank"><i class="fa-brands fa-orcid fa-xl"></i></a></div>
</div>

<div style="margin-top: 30px;"></div>

[Magdalena Chechlacz](https://www.birmingham.ac.uk/staff/profiles/psychology/chechlacz-magda) is an Assistant Professor in Cognition and Ageing at the School of Psychology, University of Birmingham. She initially trained and carried out a doctorate in cellular and molecular biology (2002). After working as a biologist (Larry L. Hillblom Foundation Fellowship at the University of California, San Diego) she decided on a career change to a more human-oriented science and neuroimaging. In order to gain formal training in cognitive neuroscience and neuroimaging, she completed a second doctorate in psychology at the University of Birmingham under the supervision of Glyn Humphreys (2012). From 2013 to 2016, she held a British Academy Postdoctoral Fellowship and EPA Cephalosporin Junior Research Fellowship, Linacre College at the University of Oxford. In 2016, Dr Chechlacz returned to the School of Psychology, University of Birmingham as a Bridge Fellow.

<div class="social-links">
<div class="social-item"><a href="mailto:m.chechlacz@bham.ac.uk"><i class="fa-solid fa-envelope fa-xl"></i> m.chechlacz@bham.ac.uk</a></div>
<div class="social-item"><a href="https://orcid.org/0000-0003-1811-3946" target="_blank"><i class="fa-brands fa-orcid fa-xl"></i> 0000-0003-1811-3946</a></div>
</div>
<br>
<p>
<img src="assets/images/main_page/aamir.png" alt="Aamir" width="250" height="200">
</p>

<h3>Aamir Sohail</h3>
<b>Role: Teaching Assistant</b>
<b style="display: block; margin-bottom: 20px;">Role: Teaching Assistant</b>
<div class="social-links" style="display: flex; flex-direction: row; gap: 5px; justify-content: flex-start;">
<div class="social-item"><a href="mailto:axs2210@bham.ac.uk"><i class="fa-solid fa-envelope fa-xl"></i></a></div>
<div class="social-item"><a href="/~https://github.com/sohaamir" target="_blank"><i class="fa-brands fa-github fa-xl"></i></a></div>
<div class="social-item"><a href="https://twitter.com/AamirNSohail" target="_blank"><i class="fa-brands fa-x-twitter fa-xl"></i></a></div>
<div class="social-item"><a href="https://orcid.org/0009-0000-6584-4579" target="_blank"><i class="fa-brands fa-orcid fa-xl"></i></a></div>
<div class="social-item"><a href="https://sohaamir.github.io/" target="_blank"><i class="fa-solid fa-globe fa-xl" style="color: #87CEEB;"></i></a></div>
</div>

[Aamir Sohail](https://sohaamir.github.io/) is an MRC Advanced Interdisciplinary Methods (AIM) DTP PhD student based at the Centre for Human Brain Health (CHBH), University of Birmingham, where he is supervised by Lei Zhang and Patricia Lockwood. He completed a BSc in Biomedical Science at Imperial College London, followed by an MSc in Brain Imaging at the University of Nottingham. He then worked as a Junior Research Fellow at the Centre for Integrative Neuroscience and Neurodynamics (CINN), University of Reading. Outside of research, he is also passionate about facilitating inclusivity and diversity in academia, as well as promoting open and reproducible science.
<div style="margin-top: 30px;"></div>

<div class="social-links">
<div class="social-item"><a href="mailto:axs2210@bham.ac.uk"><i class="fa-solid fa-envelope fa-xl"></i> axs2210@bham.ac.uk</a></div>
<div class="social-item"><a href="/~https://github.com/sohaamir" target="_blank"><i class="fa-brands fa-github fa-xl"></i> sohaamir</a></div>
<div class="social-item"><a href="https://twitter.com/AamirNSohail" target="_blank"><i class="fa-brands fa-x-twitter fa-xl"></i> AamirNSohail</a></div>
<div class="social-item"><a href="https://orcid.org/0009-0000-6584-4579" target="_blank"><i class="fa-brands fa-orcid fa-xl"></i> 0009-0000-6584-4579</a></div>
<div class="social-item"><a href="https://sohaamir.github.io/" target="_blank"><i class="fa-solid fa-globe fa-xl" style="color: #87CEEB;"></i> sohaamir.github.io</a></div>
</div>
[Aamir Sohail](https://sohaamir.github.io/) is an MRC Advanced Interdisciplinary Methods (AIM) DTP PhD student based at the Centre for Human Brain Health (CHBH), University of Birmingham, where he is supervised by Lei Zhang and Patricia Lockwood. He completed a BSc in Biomedical Science at Imperial College London, followed by an MSc in Brain Imaging at the University of Nottingham. He then worked as a Junior Research Fellow at the Centre for Integrative Neuroscience and Neurodynamics (CINN), University of Reading. Outside of research, he is also passionate about facilitating inclusivity and diversity in academia, as well as promoting open and reproducible science.

## Course Overview

Expand Down
20 changes: 10 additions & 10 deletions docs/workshop5/first-level-analysis.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Running the first-level fMRI analysis

We are now ready to proceed with running our data analysis. We will start with the first dataset (first participant `/p01`) and our first step will be to skull-strip the data using BET.
We are now ready to proceed with running our fMRI analysis. We will start with the first dataset (first participant `/p01`) and our first step will be to skull-strip the data using BET.
<b>You should now be able by now to not only run BET but also to troubleshoot poor BET i.e., use different methods to run BET.</b>

The `p01` T1 scan was acquired with a large FOV (you can check this using FSLeyes; it is generally a good practice to explore the data before the start of any analysis, especially if you were not the person who acquired the data). Therefore, we will apply an appropriate method using BET as per the example we explored earlier. This will be likely the right method to be applied to all datasets in the `/recon` folder but please check.
The `p01` T1 scan was acquired with a large field-of-view (FOV) (you can check this using FSLeyes; it is generally a good practice to explore the data before the start of any analysis, especially if you were not the person who acquired the data). Therefore, we will apply an appropriate method using BET as per the example we explored earlier. <b>This will be likely the right method to be applied to all datasets in the `/recon` folder but please check.</b>

Open a terminal and use the commands below to skull-strip the T1:

Expand All @@ -27,7 +27,7 @@ Remember that:
A poor brain extraction will affect the registration of the functional data into MNI space giving a poorer quality of registered image. This in turn will mean that the higher-level analyses (where functional data are combined in MNI space) will be less than optimal. It will then be harder to detect small BOLD signal changes in the group.

!!! tip "Re-doing inaccurate BETs"
Whenever the BET process is unsatisfactory you will need to go back and redo the individual BET extraction by hand, by tweaking the “Fractional intensity threshold” and/or the Advanced option parameters for the Centre coordinates and/or the “Threshold gradient”.
Whenever the BET process is unsatisfactory you will need to go back and redo the individual BET extraction by hand, by tweaking the “Fractional intensity threshold” and/or the advanced option parameters for the centre coordinates" and/or the “Threshold gradient”.

You should be still inside the `/p01` folder; please rename the fMRI scan by typing:

Expand Down Expand Up @@ -130,7 +130,7 @@ Set the following:
- <b>Apply external script:</b> Leave empty
- <b>Add additional confound EVs checkbox:</b> OFF

Select the Full model setup option; and then on the 'EVs' tab:
Select the 'Full model setup' option (depicted on the blue arrow above); and then on the 'EVs' tab:

- <b>1 EV (Explanatory variable) name:</b> vision
- <b>Basic shape:</b> square
Expand Down Expand Up @@ -166,7 +166,7 @@ The model should now be set up with all the correct details and be ready to be a

<b>Hit the GO button!</b>

!!! note "Running FSL on BlueBEAR"
!!! tip "Running FSL on BlueBEAR"
FSL jobs are now submitted in an automated way to a back-end high performance computing cluster on BlueBEAR for execution. Processing time for this analysis will vary but will probably be about 5 mins per run.

## Monitoring and viewing the results
Expand All @@ -179,7 +179,7 @@ To do that, you need to navigate inside the `p01_s1.feat` folder from the BlueBE
<img src="../../assets/images/workshop5/first-level/feat_directory.png" alt="FEAT Directory" width="600" height="300">
</p>

Watch the webpage for progress. Refresh the page to update and click the links (Tabs near the top of the page) to see the results when available (the 'STILL RUNNING' message will disappear).
Watch the webpage for progress. Refresh the page to update and click the links (the tabs near the top of the page) to see the results when available (the 'STILL RUNNING' message will disappear when the analysis has finished).

<p align="center">
<img src="../../assets/images/workshop5/first-level/feat_progress.png" alt="FEAT Progress" width="1000" height="300">
Expand Down Expand Up @@ -215,15 +215,15 @@ Open the `p01_s1.feat` folder and select the `filtered_func_data` (this is the f

Let's have a look and see the effects that other parameters have on the data. To do this, do the following steps:

- Open FEAT (either through the GUI or the terminal by `Feat &`)
- Open FEAT (either through the GUI or using the terminal by typing `Feat &`)
- Press the 'Load' button and open the `design.fsf` file in the `p01_s1.feat` directory for the first participant
- Change <b>any one</b> of the parameters – some make very little difference but ones that should have some difference are:
- Motion parameters: change from 'Standard Motion Parameters' to 'Don't Add Motion Parameters'
- Spatial smoothing (previously set to 5mm): try increasing to 10mm
- Set High pass filter to 30sec (i.e. 50% less than OFF+ON time period).
- High pass filter: set to 30sec (i.e. 50% less than OFF+ON time period).
- Hit 'Go'

<b>Note that each time you rerun Feat, it creates a new folder with a '+' sign in the name.</b> So you will have folders rather messily named 'p01_s1.feat', “'01_s1+.feat', 'p01_s1+ +.feat', and so on. This is rather wasteful of of your precious quota space, so you should delete unnecessary ones after looking at them.
<b>Note that each time you rerun Feat, it creates a new folder with a '+' sign in the name.</b> So you will have folders rather messily named 'p01_s1.feat', 'p01_s1+.feat', 'p01_s1++.feat', and so on. This is rather wasteful of of your precious quota space, so you should delete unnecessary ones after looking at them.

For example, if you wanted to remove all files and directories that end with '+' for participant 1:

Expand All @@ -249,7 +249,7 @@ To rerun a FEAT analysis, rather than re-entering all the model details:
Now change the input 4D file, the output directory name, and the registration details (the BET'ed reoriented T1 for participant 2), and hit 'Go'.

!!! note "Design files"
You can also save the design files (`design.fsf`) using the 'Save' button on the FEAT GUI. You can then edit this in a text editor, which is useful when running large group studies. You can also run FEAT from the command line, by giving it a design file to use e.g., `feat my_saved_design.fsf`. We will take a look at modifying the `design.fsf` files directly in the [Functional Connectivity workshop](https://chbh-opensource.github.io/mri-on-bear-edu/workshop8/functional-connectivity/).
You can also save the design files (`design.fsf`) using the 'Save' button on the FEAT GUI. You can then edit this in a text editor, which is useful when running large group studies. You can also run FEAT from the command line, by giving it a design file to use e.g., `feat my_saved_design.fsf`. We will take a look at modifying `design.fsf` files directly in the [Functional Connectivity workshop](https://chbh-opensource.github.io/mri-on-bear-edu/workshop8/functional-connectivity/).

!!! example "Running a first-level analysis on the remaining participants"
In your own time, you should analyse the remaining participants as above.
Expand Down
27 changes: 15 additions & 12 deletions docs/workshop5/preprocessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ However, in this case we can see different parameters being used which reflect s
!!! note "Sequence order"
Note that sometimes the T1 was the first scan acquired after the planning scan, sometimes it was the very last scan acquired.

Now that we know what the data is, let's start our analyses. Log in into BlueBEAR portal and start BlueBEAR GUI session (2 hours). You should know how to do it from previous workshops.
Now that we know what the data is, let's start our analyses. Log in into the BlueBEAR Portal and start a BlueBEAR GUI session (2 hours). You should know how to do it by now from previous workshops.

Open a new terminal window and navigate to your MRICN project folder:

`cd /rds/projects/c/chechlmy-chbh-mricn/xxx` [where XXX=your ADF username]

Please check that you are in the correct directory by typing `pwd`. This should return: `/rds/projects/c/chechlmy-chbh-mricn/xxx` (where XXX = your login username)
Please check that you are in the correct directory by typing `pwd`. This should return:

`/rds/projects/c/chechlmy-chbh-mricn/xxx` (where XXX = your login username)

You now need to create a copy of the reconstructed fMRI data to be analysed during the workshop but in your own MRICN folder. To do this, in your terminal type:

`cp -r /rds/projects/c/chechlmy-chbh-mricn/module_data/recon/ .`

<b>Be patient as this might take few minutes to copy over.</b> In the meantime, we will revisit BET and learn how to troubleshoot the often problematic process of ”skull-stripping”.

<br>
<b>Be patient as this might take few minutes to copy over.</b> In the meantime, we will revisit BET and learn how to troubleshoot the often problematic process of 'skull-stripping'.

## Skull-stripping T1 scans using BET on the command-line
We will now look at how to ”skull-strip” the T1 image (remove the skull and non-brain areas), as this step is needed as part of the registration step in the fMRI analysis pipeline.
Expand Down Expand Up @@ -79,7 +79,7 @@ After this, navigate inside the copied BET folder and type:

Open FSLeyes (`fsleyes &`), and when this is open, load up the T1 image, and add the `T1_brain1` image. Change the colour for the `T1_brain1` to Red.

<b>This will likely show that the default brain extraction was not very good and included nonbrain matter.</b> It may also have cut into the brain and thus some part of the cortex is missing. The reason behind the poor brain extraction is a large FOV (resulting in the head plus a large amount of neck present).
<b>This will likely show that the default brain extraction was not very good and included non-brain matter.</b> It may also have cut into the brain and thus some part of the cortex is missing. The reason behind the poor brain extraction is a large field-of-view (FOV) (resulting in the head plus a large amount of neck present).

There are different ways to fix a poor BET output i.e., problematic ”skull-stripping”.

Expand All @@ -91,7 +91,8 @@ In your terminal type:

`bet T1.nii.gz T1_brain2 -R`

Instead of using the `bet` command from the terminal, you can also use the BET GUI. To run it this way, you would need to select the processing option “Robust brain centre estimation (iterates bet2 several times)” from the pull down menu.
!!! note "Running BET recursively from the BET GUI"
Instead of using the `bet -R` command from the terminal, you can also use the BET GUI. To run it this way, you would need to select the processing option “Robust brain centre estimation (iterates bet2 several times)” from the pull down menu.

You will find that running BET with `-R` option takes longer than before because of the extra iterations. Reload the newly extracted brain (`T1_brain2`) into FSLeyes and check that the extraction now looks improved.

Expand All @@ -114,9 +115,11 @@ Reload the newly extracted brain (`T1_brain3`) into FSLeyes and compare it to `T
Another option is to leave the large FOV and to manually set the initial centre by hand via the `-c` option on the command line.
To do that you need to firstly examine the T1 scan in FSLeyes to get a rough estimation (in voxels) of where the centre of the brain is.

There is another BET option, which can improve ”skull stripping”, the fractional intensity threshold, which by default is set to 0.5.
There is another BET option which can improve ”skull stripping”: the fractional intensity threshold, which by default is set to 0.5.
You can change it from any value between 0-1. <b>Smaller values give larger brain outline estimates (and vice versa).</b>
Thus, you can make it smaller if you think that too much brain tissue has been removed. To use it, you need to use the `-f` option (e.g., `bet T1.nii.gz T1_brain -f 0.3`).
Thus, you can make it smaller if you think that too much brain tissue has been removed.

To use it, you would need to use the `-f` option (e.g., `bet T1.nii.gz T1_brain -f 0.3`).

!!! example "Changing the fractional intensity"
In your own time (after the workshop) you can check the effect of changing the fractional intensity threshold to 0.1 and 0.9 (however make sure you name the outputs accordingly, so you know which one is which).
Expand Down Expand Up @@ -162,7 +165,7 @@ However, apart from the T1 images that have been already renamed for you, the ot
You can see this by typing into your terminal:

```bash
cd /rds/projects/c/chechlmy-chbh-mricn/xxx/recon/p03
cd /rds/projects/c/chechlmy-chbh-mricn/xxx/recon/p03
ls
```

Expand All @@ -187,7 +190,7 @@ immv fs005a001 fmri2

- The 'immv' command is a special FSL Linux command that works just like the standard Linux `mv` command except that it automatically takes care of the filename extensions. It saves from having to write out:
`mv fs004a001.nii.gz fmri1.nii.gz` which would be the standard Linux command to rename a file.
- You can of course name these files to anything you want. In principle, you could call the fMRI scan `run1` or `fmri_run1` or `epi1` or whatever. The important thing is that you need to be extremely consistent in the naming of files for the different participants.
- You can of course name these files to anything you want. In principle, you could call the fMRI scan `run1` or `fmri_run1` or `epi1` or whatever. <b>The important thing is that you need to be extremely consistent in the naming of files for the different participants.</b>

For this workshop we will use the naming convention above and call the files `fmri1.nii.gz` and `fmri2.nii.gz`.

Expand Down Expand Up @@ -218,4 +221,4 @@ You should see something like the image below:
<img src="../../assets/images/workshop5/preprocessing/fslinfo.png" alt="FSLinfo" width="700" height="300">
</p>

Before proceeding to the next section, close your terminal.
Before proceeding to the next section on running a first-level fMRI analysis, close your terminal.
2 changes: 1 addition & 1 deletion docs/workshop5/workshop5-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We will also revisit the use of Brain Extraction Tool (BET), and learn how to tr
!!! success "Overview of Workshop 5"
Topics for this workshop include:

- Troblueshooting problematic skull-stripping by using BET options (recursive BET, `robustfov`)
- Troubleshooting problematic skull-stripping by using BET options (recursive BET, `robustfov`)
- Renaming fMRI data and understanding the importance of having suitable file names
- Running a first-level fMRI analysis on single subjects using FEAT
- Examining the processed fMRI data using the FEAT Report and FSLeyes
Expand Down
Loading

0 comments on commit ad71b82

Please sign in to comment.