diff --git a/docs/assets/images/workshop5/first-level/data.png b/docs/assets/images/workshop5/first-level/data.png new file mode 100644 index 0000000..2496c75 Binary files /dev/null and b/docs/assets/images/workshop5/first-level/data.png differ diff --git a/docs/assets/images/workshop5/first-level/feat_directory.png b/docs/assets/images/workshop5/first-level/feat_directory.png new file mode 100644 index 0000000..f29f428 Binary files /dev/null and b/docs/assets/images/workshop5/first-level/feat_directory.png differ diff --git a/docs/assets/images/workshop5/first-level/feat_progress.png b/docs/assets/images/workshop5/first-level/feat_progress.png new file mode 100644 index 0000000..a9e2d77 Binary files /dev/null and b/docs/assets/images/workshop5/first-level/feat_progress.png differ diff --git a/docs/assets/images/workshop5/first-level/feat_report.png b/docs/assets/images/workshop5/first-level/feat_report.png new file mode 100644 index 0000000..d2ce361 Binary files /dev/null and b/docs/assets/images/workshop5/first-level/feat_report.png differ diff --git a/docs/assets/images/workshop5/first-level/fsleyes_camera.png b/docs/assets/images/workshop5/first-level/fsleyes_camera.png new file mode 100644 index 0000000..70d2303 Binary files /dev/null and b/docs/assets/images/workshop5/first-level/fsleyes_camera.png differ diff --git a/docs/assets/images/workshop5/first-level/pre_stats.png b/docs/assets/images/workshop5/first-level/pre_stats.png new file mode 100644 index 0000000..4a9197c Binary files /dev/null and b/docs/assets/images/workshop5/first-level/pre_stats.png differ diff --git a/docs/assets/images/workshop5/first-level/stats.png b/docs/assets/images/workshop5/first-level/stats.png new file mode 100644 index 0000000..f1c640c Binary files /dev/null and b/docs/assets/images/workshop5/first-level/stats.png differ diff --git a/docs/assets/images/workshop5/preprocessing/experiment_design.png b/docs/assets/images/workshop5/preprocessing/experiment_design.png new file mode 100644 index 0000000..5d9f1e9 Binary files /dev/null and b/docs/assets/images/workshop5/preprocessing/experiment_design.png differ diff --git a/docs/assets/images/workshop5/preprocessing/fslinfo.png b/docs/assets/images/workshop5/preprocessing/fslinfo.png new file mode 100644 index 0000000..6d4416c Binary files /dev/null and b/docs/assets/images/workshop5/preprocessing/fslinfo.png differ diff --git a/docs/workshop5/brain-extraction.md b/docs/workshop5/brain-extraction.md deleted file mode 100644 index e69de29..0000000 diff --git a/docs/workshop5/first-level-analysis.md b/docs/workshop5/first-level-analysis.md index e69de29..c6632d4 100644 --- a/docs/workshop5/first-level-analysis.md +++ b/docs/workshop5/first-level-analysis.md @@ -0,0 +1,273 @@ +# 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. +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. + +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. + +Open a terminal and use the commands below to skull-strip the T1: + +```bash +cd /rds/projects/c/chechlmy-chbh-mricn/xxx/recon/p01 +module load FSL/6.0.5.1-foss-2021a +module load FSLeyes/1.3.3-foss-2021a +immv T1 T1neck +robustfov -i T1neck -r T1 +bet T1.nii.gz T1_brain -R +``` + +Remember that: + +- The `immv` command renames the T1 image, and automatically takes care of the filename extensions +- The `robustfov` command crops the image and names it back to `T1.nii.gz` +- The `bet -R` command runs BET recursively + +It is very important that after running BET that you examine, using FSLeyes, the quality of the brain extraction process performed on each and every T1. + +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”. + +You should be still inside the `/p01` folder; please rename the fMRI scan by typing: + +`immv fs005a001 fmri1` + +## Setting up and running the first-level fMRI analysis using FEAT + +We are now ready to proceed with our fMRI data analysis. To do that we will need a different version of FSL installed on BlueBEAR. Close your terminal and again navigate inside the `p01` folder: + +`cd /rds/projects/c/chechlmy-chbh-mricn/xxx/recon/p01` + +Now load FSL using the commands below: + +```bash +module load bear-apps/2022b +module load FSL/6.0.7.6 +source $FSLDIR/etc/fslconf/fsl.sh +``` + +Finally, open FEAT (from the FSL GUI or by typing `Feat &` in a terminal window). + +On the menus, make sure 'First-level analysis' and 'Full analysis' are selected. Now work through the tabs, setting and changing the values for each parameter as described below. +Try to understand how these settings relate to the description of the experiment as provided at the start. + +

+ FEAT Data +

+ +

Misc Tab

+ +Accept all the defaults. + +

Data Tab

+ +Input file + +The input file is the 4D fMRI data (the functional data for participant 1 should be called something like `fmri1.nii.gz` if you have renamed it as above). Select this using the 'Select 4D data' button. Note that when you have selected the input, 'Total volumes' should jump from 0. + +!!! warning "Total volumes troubleshooting" + If “Total volumes” is still set to 0, or jumps to 1, you have done something wrong. If you get this, stop and fix the error at this point. DO NOT CARRY ON. If “Total volumes” is still set to 0, that means you have not yet selected any data. Try again. If “Total volumes” is set to 1, that means you have most likely selected the T1 image, not the fMRI data. Try again, but selecting the correct file. + +Check carefully at this point that the total number of volumes is correct (93 volumes were collected on participants 1-2, 94 volumes on participants 3-15). + +Output directory + +Enter a directory name in the output directory. This needs to be something systematic that you can use for all the participants and which is comprehensible. +It needs to make sense to you when you look at it again in a year or more in the future. It is important here to use full path names. +It is also very important that you do not use shortened or partial path names and that you do not put any spaces in the filenames you use. +If you do, these may cause some programs to crash with errors that may not seem to make much sense. + +For example, use an output directory name like: + +`/rds/projects/c/chechlmy-chbh-mricn/xxx/feat/1/p01_s1` + +where: + +- `/rds/projects/c/chechlmy-chbh-mricn/xxx/feat` is the top level directory where you intend to put all of your upcoming FEAT analyses for the experiment +- `/rds/projects/c/chechlmy-chbh-mricn/xxx/feat/1` is the sub-directory where you intend to put specifically only the 1st level (per session) FEAT analyses (and not the 2nd or higher level analyses). `p01` refers to participant 1 and `s1` refers to session/scan 1 + +Note that when FEAT is eventually run this will automatically create a new directory called `/rds/projects/c/chechlmy-chbh-mricn/xxx/feat/1/p01_s1.feat` for you containing the output of this particular analysis. If the directory structure does not exist, FEAT will try and make it. You do not need to make it yourself in advance. + +Repetition Time (TR) + +For this experiment make sure that the TR is set to 2.0s. If FEAT can read the TR from the header information it will try and set it automatically. If not you will need to set it manually. + +High pass filter cutoff + +Set 'High pass filter cutoff' to 60sec (i.e. 50% greater than OFF+ON length of time). + +

Pre-stats

+ +

+ FEAT Pre-stats +

+ +Set the following: + +- Alternative reference image checkbox: OFF +- Motion Correction: Select McFLIRT +- B0 unwarping checkbox: OFF +- Slice timing: Select “Regular up” (Some researchers advise against slice timing correction, however we will use it here to illustrate the process). +- Bet brain extraction checkbox: ON +- Spatial smoothing: 5mm +- Intensity normalization: OFF +- Temporal filtering – Perfusion Subtraction checkbox: OFF +- Highpass checkbox: ON +- Melodic ICA data exploration checkbox: OFF + +

Stats

+ +

+ FEAT Stats +

+ +Set the following: + +- Use FILM prewhitening checkbox: ON +- Motion parameters: Select the option “Standard Motion Parameters” +- Voxelwise confound List: Leave empty +- Apply external script: Leave empty +- Add additional confound EVs checkbox: OFF + +Select the “Full model setup” option; and then on the 'EVs' tab: + +- 1 EV (Explanatory variable) name: vision +- Basic shape: square +- Skip: 0s +- OFF: 20s +- ON: 20s +- phase: 0 +- stop: 180 +- Convolution: select defaults (Gamma: 0,3,6) + +On the Contrasts Tab: + +- We have 1 contrast, name it 'vision', and then click done + +Check the plot of the design that will be generated and then click on the image to dismiss it. + +

Post-stats

+ +Change the 'Thresholding' pull down option to be of type 'Uncorrected' and leave the P threshold value at p<0.05. + +!!! note "Thresholding and processing time" + Note this is not the correct thresholding that you will want at the final (third stage) of processing (where you will probably want 'Cluster thresholding') but for the convenience of the workshop, at this stage it will speed up the processing per run. + +

Registration

+ +Set the following: + +- Click the checkbox for 'Main structural image' and choose the BET’ed anatomical (i.e. participant 1's `T1_brain.nii.gz`) as the main structural image with 'Linear Options: Normal search, BBR' +- Accept the default as the standard brain with 'Linear Options: Normal search, 12 DOF' +- Make sure the 'Nonlinear' checkbox is set to 'OFF' + +The model should now be set up with all the correct details and be ready to be analyzed. + +Hit the GO button! + +!!! note "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 data + +FEAT has a built-in progress watcher, the 'FEAT Report', which you can open in a web browser. + +To do that, you need to navigate inside the `p01_s1.feat` folder from the BlueBEAR Portal as below and from there select the `report.html` file, and either open it in a new tab or in a new window. + +

+ FEAT Directory +

+ +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). + +

+FEAT Progress +

+

Example FEAT Reports for processes that are still running, and which have completed.

+ +
+ +After it has completed, first look at the webpage, click on the various links and try to understand what each part means. + +

+ FEAT Report +

+ +Now let's use FSLeyes to look at the output in more detail. To do that you will need to open a separate terminal and load FSLeyes: + +```bash +cd /rds/projects/c/chechlmy-chbh-mricn/xxx/recon/p01 +module load FSL/6.0.5.1-foss-2021a-fslpython +module load FSLeyes/1.3.3-foss-2021a +fsleyes & +``` + +Open the `p01_s1.feat` folder and select the `filtered_func_data` (this is the fMRI data after it has been preprocessed by motion correction etc). + +Put FSLeyes into movie mode and see if you can identify areas that change in activity. + +Now, add the `thresh_zstat1` image and try to identify the time course of the stimulation in some of the most highly activated voxels. You should remember how to complete the above tasks from [previous workshops](https://chbh-opensource.github.io/mri-on-bear-edu/workshop2/visualizing-mri-data/). You can also use the “camera” icon to take a snapshot of the results. + +

+ FSL Camera +

+ +

Seeing the effect of other parameters

+ +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 &`) +- Press the 'Load' button and open the `design.fsf` file in the `p01_s1.feat` directory for the first participant +- Change any one 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). +- Hit 'Go' + +Note that each time you rerun Feat, it creates a new folder with a '+' sign in the name. 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. + +For example, if you wanted to remove all files and directories that end with '+' for participant 1: + +```bash +cd /rds/projects/c/chechlmy-chbh-mricn/xxx/feat/1/ +rm -rf *+ +``` + +You might want also to change the previous output directory name to have a more meaningful name in order to make it more obvious what parameter has changed, e.g. `p01_s1_motion_off.feat`. + +

Analysing other participants' data

+ +For participant 2, you will need to repeat the main steps above: + +- Rename the files to be consistent with your naming scheme for participant `p01` +- Skull strip the reoriented T1 scan (and check it is done properly) +- Run FEAT + +To rerun a FEAT analysis, rather than re-entering all the model details: + +- Open FEAT, press the 'Load' button and open the 'design.fsf' file in the FEAT directory from participant `p01` + +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/). + +!!! example "Running a first-level analysis on the remaining participants" + In your own time, you should analyse the remaining participants as above. + + Remember: + + - Participants 1-2 have only one fMRI run each (i.e. 2 people x 1 run each = 2 runs) + - Participant 5 has 3 fMRI runs (i.e. 1 person x 3 runs = 3 runs) + - Participants 3-4 and 6-15 have 2 fMRI runs each (i.e. 12 people x 2 runs = 24 runs) + + There are therefore 29 separate analyses that need to be done. + + - Analyze each of these 29 fMRI runs independently and put the output of each one into a separate, clearly labelled directory as suggested above. + - Try and get all these done before the next fMRI workshop in week 10 on higher level fMRI analysis as you will need this processed data for that workshop. You have two weeks to complete this task. + +!!! tip "Scripting your analysis" + It will seem laborious to re-write and re-run 29 separate FEAT analyses; a much quicker way is by scripting our analyses using `bash`. If you would like, try scripting your analyses! Contact one of the course TA's or convenors if you are stuck! + +As always, help and further information is also available on the relevant section of the [FSL Wiki](https://fsl.fmrib.ox.ac.uk/fsl/docs/#/task_fmri/feat/index). diff --git a/docs/workshop5/preprocessing-fmri.md b/docs/workshop5/preprocessing-fmri.md deleted file mode 100644 index e69de29..0000000 diff --git a/docs/workshop5/preprocessing.md b/docs/workshop5/preprocessing.md new file mode 100644 index 0000000..57f367b --- /dev/null +++ b/docs/workshop5/preprocessing.md @@ -0,0 +1,220 @@ +# Pre-processing the functional MRI data + +In the first part of the workshop, + +

Background and set-up

+ +The data that we will be using are data collected from 15 participants scanned on the same experimental protocol on the Phillips 3T scanner (our old scanner). + +The stimulus protocol was a visual checkerboard reversing at 2Hz (i.e., 500ms between each reversal) and was presented alternately (20s active “on” checkerboard, 20s grey screen “off”), +starting and finishing with “off” and including 4 blocks of “on” (i.e., off, on, off, on, off, on, off, on, off) = 180 sec. + +A few extra seconds of “off” (6-8s) were later added at the very end of the run to match the number of volumes acquired by the scan protocol. + +

+ Design +

+ +Normally in any experiment it is very important to keep all the protocol parameters fixed when acquiring the neuroimaging data. +However, in this case we can see different parameters being used which reflect slightly different “best choices” made by different operators over the yearly demonstration sessions: + +- The repetition time and voxel size were the same for all scans: (TR = 2000 ms, voxel size 2.5 x 2.5 x 2.5mm). +- However, 93 volumes were collected on participants 1-2, 94 volumes on all later participants. +- The first 11 participants were scanned with an 8-channel head coil, acquiring 32 slices in ascending order, whilst participants 12-15 were scanned with a 32-channel head coil, acquiring 30 slices in ascending order. +- Each participant always also had a planning scan (i.e., so called anatomical localizer, this was always scan 1 and can be ignored), a T1 anatomical scan and one or more fMRI scans. +- Participants 1-2 performed only 1 functional sequence, participants 3-4 and 6-15 performed 2 functional sequences, and participant 5 performed 3 functional sequences. + +!!! 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. + +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) + +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/ .` + +Be patient as this might take few minutes to copy over. 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. +We will do this using FSL's BET on the command line. As you should know from previous workshops the basic command-line version of BET is: + +(do not type this command, this is just a reminder) + +`bet [options]` + +where: + +- input = you need to specify input image (e.g., `T1_scan`) +- output = filename of BET output (e.g., `T1_brain`) +- options = controls how to run BET + +We will firstly explore the different options and how to troubleshoot brain extraction. + +If the fMRI data has finished copying over, you can use the same terminal which you have previously opened. +If not, keep that terminal open and instead open a new terminal, navigating inside your MRICN project folder (i.e., `/rds/projects/c/chechlmy-chbh-mricn/xxx`) + +Next you need to copy the data for this part of the workshop. As there is only 1 file, it will not take a long time. Type: + +`cp -r /rds/projects/c/chechlmy-chbh-mricn/module_data/BET/ .` + +And then load FSL and FSLeyes by typing: + +```bash +module load FSL/6.0.5.1-foss-2021a +module load FSLeyes/1.3.3-foss-2021a +``` + +After this, navigate inside the copied BET folder and type: + +`bet T1.nii.gz T1_brain1` + +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. + +This will likely show that the default brain extraction was not very good and included nonbrain matter. 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). + +There are different ways to fix a poor BET output i.e., problematic ”skull-stripping”. + +First of all, you can use the `-R` option. + +This option is used to run BET in an iterative fashion which allows it to better determine the centre of the brain itself. + +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. + +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. + +In the case of T1 images with a large FOV, you can first crop the image (to remove portion of the neck) and run BET again. To do that you need to use command `robustfov` before applying BET. But first rename the original image. + +Type in your terminal: + +``` bash +immv T1 T1neck` +robustfov -i T1neck -r T1 +bet T1.nii.gz T1_brain3 -R +``` + +- The first command renames the T1 image, and automatically takes care of the filename extensions. +- The second command crops the image and names it back to `T1.nii.gz` +- The third command runs BET again with the recursive `-R` option. + +Reload the newly extracted brain (`T1_brain3`) into FSLeyes and compare it to `T1_brain1` and to check that the extraction looks improved. Also compare the cropped T1 image to the original one with a large FOV (`T1neck`). + +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. +You can change it from any value between 0-1. Smaller values give larger brain outline estimates (and vice versa). +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`). + +!!! 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). + +It is very important that after running BET you always examine (using FSLeyes) the quality of the brain extraction process performed on each and every T1. + +The strategy you might need to use could be different for participants in the same study. You might need to try different options. The general recommendation is to combine the cropping (if needed) and the `-R` option. +However, it may not work for all T1 scans, some types of T1 scans work better with one strategy than with another. Therefore, it is good to always try a range of options. + +Now you should be able to “skull-strip” T1 scans as needed for fMRI analyses! + +## Exploring the data and renaming the MRI scan files +By now you should have a copy of the reconstructed fMRI data in your own folder. As described above, the `/recon` version of the directory contains the MRI data from 15 participants acquired over several years from various site visits. + +The datasets have been reconstructed into the NIFTI format. The T1 images in each directory are named `T1.nii.gz`. The first (planning) scan sequences (localisers) have been removed in each directory as these will not be needed for any subsequent analysis we are doing. + +Navigate inside the `recon` folder and list the contents of these directories (using the `ls` command) to make sure they actually contain imaging files. Note that all the imaging data here should be in NIFTI format. + +You should see the set of participant directories labelled `p01`, `p02` etc., all the way up to the final directory,`p15`. + +The directory structure should look like this: + +```bash +~/chechlmy-chbh-mricn/xxx/recon/ + ├── p01/ + ├── p02/ + ├── p03/ + ├── p04/ + ├── p05/ + ├── ... + ├── p13/ + ├── p14/ + └── p15/ +``` +!!! warning "Verifying the data structure" + Please verify that you have this directory structure before proceeding! + +Explore what’s inside each participant folder. Please note that each participant folder only contains reconstructed data. It’s a good idea to store raw and reconstructed data separately. At this point you should have access to reconstructed participants `p01` to `p15`. The reconstructed data should be in folders named `~/chechlmy-chbh-mricn/xxx/recon/p01` etc. + +However, apart from the T1 images that have been already renamed for you, the other reconstructed files in this directory will have unusual names, created automatically by the `dcm2nii` conversion program. + +You can see this by typing into your terminal: + +```bash +cd /rds/projects/c/chechlmy-chbh-mricn/xxx/recon/p03 +ls +``` + +Which should list: + +```bash +fs004a001.nii.gz +fs005a001.nii.gz +T1.nii.gz +``` + +It is poor practice to keep with these names as they do not reflect the actual experiment and will likely be a source of confusion later on. We should therefore rename the files to be something meaningful. + For this participant (`p03`) the first fMRI scan is file 1 (`fs004001.nii.gz`) and the second fMRI scan is file 2 (`fs005a001.nii.gz`). Rename the files as follows (to do that you need to be inside folder `p03`): + +```bash +immv fs004a001 fmri1 +immv fs005a001 fmri2 +``` + +!!! example "Renaming files" + Notes: + + - 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. + +For this workshop we will use the naming convention above and call the files `fmri1.nii.gz` and `fmri2.nii.gz`. + +As the experimenter you would normally be familiar with the order of acquisition of the different sequences and therefore the order of the resulting files created, including which one is the T1 image. You would write these down in your research log book whilst acquiring the MRI data. But sometimes, as here, if data is given to you later it may not be clear which particular file is the T1 image. + +There are several ways to figure this out: + +1. The very first file will always (unless it has been deleted before it got to you) be a planning scan (localizer). This can be ignored. In general, the T1 image is very likely to be either the second file or the very last file. +2. If you look at the list of file sizes (using `ls -al`) you should be able to see that the T1 image is smaller than most typical EPI fMRI images. Also, if there are more than one fMRI sequences (as here with `p03` onwards) you will also see that several files have the same file size and the odd one out is the T1. +3. If you load the images into FSLeyes and look at them individually it should be very obvious which image is the T1. Remember the T1 image is a single volume, in high spatial resolution. It will also likely have a much larger field of view (showing all of the skull and part of the spine). The fMRI images will consist of many volumes (click through several volumes to check), be of lower spatial resolution (it will look coarser) and have a more limited field of view. + +If you have access to the NIFTI format files (`.nii.gz` as we have here) then you can use one of the FSL command line tools (in a terminal window) called `fslinfo` to examine the protocol information on the file. +This will show you the number of volumes in the acquisition (remember this is 1 volume for a T1 image) as well as other information about the number of voxels and the voxel size. + +Together this information is sufficient to work out which file is the T1 and which are the fMRI sequence(s). + +For example if you type the following in your terminal: + +```bash +cd .. +cd p08 +fslinfo fs005a001.nii.gz +``` + +You should see something like the image below: + +

+ FSLinfo +

+ +Before proceeding to the next section, close your terminal. \ No newline at end of file diff --git a/docs/workshop5/workshop5-intro.md b/docs/workshop5/workshop5-intro.md new file mode 100644 index 0000000..664744a --- /dev/null +++ b/docs/workshop5/workshop5-intro.md @@ -0,0 +1,25 @@ +# Workshop 5 - First level fMRI analysis + +Welcome to the fifth workshop of the MRICN course! + +The module lectures provide a basic introduction to fMRI concepts and the theory behind fMRI analysis, including the physiological basis of the BOLD response, fMRI paradigm design, pre-processing and single subject model-based analysis. + +In this workshop you will learn how to analyse fMRI data for individual subjects (i.e., at the first level). This includes running all pre-processing stages and the first level fMRI analysis itself. +The aim of this workshop is to introduce you to some of the core FSL tools used in the analysis of fMRI data and to gain practical experience with analyzing real fMRI data. + +Specifically, we will explore [FEAT](https://fsl.fmrib.ox.ac.uk/fsl/docs/#/task_fmri/feat/index) (FMRI Expert Analysis Tool, part of FSL) to walk you through basic steps in first level fMRI analysis. +We will also revisit the use of Brain Extraction Tool (BET), and learn how to troubleshoot problematic ”skull-stripping” for certain cases. + +!!! success "Overview of Workshop 5" + Topics for this workshop include: + + - Troblueshooting 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 + +We will not go into details as to why and how specific values of the default settings have been chosen. +Some values should be clear to you from the lectures or resource list readings, please check there or if you are still unclear feel free to ask. +We will explore some general examples. Note that for your own projects you are very likely to want to change some of these settings/parameters depending on your study aims and design. + +The copy of this workshop notes can be found on Canvas 39058 - LM Magnetic Resonance Imaging in Cognitive Neuroscience in Week 05 workshop materials. \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 9ad8e5b..9032606 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -65,8 +65,8 @@ nav: - Workshop 4 - Aims and objectives: workshop4/workshop4-intro.md - Probabilistic tractography: workshop4/probabilistic-tractography.md - Workshop 5 - First-level fMRI analysis: - - Manual and automatic brain extraction: workshop5/brain-extraction.md - - Preprocessing of functional MRI data: workshop5/preprocessing-fmri.md + - Workshop 5 - Aims and objectives: workshop5/workshop5-intro.md + - Pre-processing the fMRI data: workshop5/preprocessing.md - Running a first-level analysis: workshop5/first-level-analysis.md - Workshop 6 - Higher-level fMRI analysis: - Setting up and running a higher-level analysis using the FSL GUI: workshop6/higher-level-analysis.md