Jerrold Jeyachandra
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # MRI Analysis in Python This is a collaborative scratchpad to shares resources related to the analysis and pre-processing of fMRI data. This notepad will be updated during the duration of the course! ## Neuroimaging Forum [Neurostars](https://neurostars.org) is a community forum for asking questions specific to neuroimaging. You can use this as a resource if you have specific questions you'd like to ask the community about ## Workshop Resources [**ATTENDENCE TEST**](https://support.scinet.utoronto.ca/education/mods/_standard/tests/test_intro.php?tid=200) - [Setup Guide](https://docs.google.com/document/d/1KaKtm17ABOBce0vLBaIlwSsb4PPbdDJsueh1Cf67TpI/edit?usp=sharing) - [Slides](https://docs.google.com/presentation/d/10y_padozF4URvHDzjwFFqhDFBmCLumz2Gfe_3K59Reg/edit?usp=sharing) - [fMRIPrep Slides](https://oesteban.github.io/ohbm19/#1) - [Git Repo](https://github.com/carpentries-incubator/SDC-BIDS-fMRI) ## Preprocessing Resources These are all BIDS-compatible pipelines! Meaning that once your dataset is in BIDS format you can run these on your dataset quite easily! - [fMRIPrep - pipeline for pre-processing fMRI data](https://fmriprep.org/en/stable/) - [MRIQC - for basic quality assessment of BIDS dataset](https://mriqc.readthedocs.io/en/latest/) - [Ciftify - for surface based analysis of fMRI data on any dataset](https://edickie.github.io/ciftify/#/) - [HCPPipelines - for Human Connectome Project surface-based preprocessing](https://github.com/BIDS-Apps/HCPPipelines) - Note that HCPPipelines is meant for HCP-like acquisitions, *it is not compatible with every dataset*! Use **Ciftify** for everything else! ## Analysis Resources ### General - [Handbook of fMRI Analysis](http://www.leixulab.net/paper/2011HandbookfMRI.pdf) - You can learn about some of the theory behind fMRI data analysis as told by some experts in the field - [Mumford Brain Stats](https://www.youtube.com/c/mumfordbrainstats/videos) - A series of Youtube tutorials on fMRI analysis. Many of the videos use FSL or SPM rather than Python but the concepts are still relevant. - [Nilearn Tutorials](https://nilearn.github.io/auto_examples/index.html) - You can find similar materials to what the course covers over here as well as more advanced material such as Machine Learning methods on neuroimaging data - [MVPA Meanderings](http://mvpa.blogspot.com/) - Excellent series of blog posts on various topics in fMRI neuroimaging analysis - [Connectome Workbench (Advanced)](https://www.humanconnectome.org/software/connectome-workbench) - This tool provides utilities for surface-based analysis of fMRI data. Surface-based analysis has many benefits over the traditional volumetric form of fMRI analysis see [this paper by fellow co-instructor, Erin Dickie](https://pubmed.ncbi.nlm.nih.gov/31091476/) which discusses this topic - Note: you will need to project your fMRI data to the surface for this tool. This can be achieved using **Ciftify** or **HCPpipelines** which are linked above in this doc. ### Confound Regression Choosing which confound regressors to use in your analysis is tricky and there's a lot of discussion in the community about the trade-offs made by each motion estimator. Below are a few papers to help guide your decision-making process for choosing confund regressors: - [Benchmarking of participant-level confound regression strategies for the control of motion artifact in studies of functional connectivity](https://www.sciencedirect.com/science/article/pii/S1053811917302288) - [Recent progress and outstanding issues in motion correction in resting state fMRI](https://pubmed.ncbi.nlm.nih.gov/25462692/) ## Assignment TBD ## Q&A During the duration of the course you may have questions that pop up after each session. If you post them here, we'll try to cover them at the beginning of each session! *** **Q** For the last part of the Day 1 exercise (getting the native functional data), is using layout.get(..., space='T1w') okay? The solution still uses a for loop so just wanted to double check. **A** Great observation! Yes you can just use space="T1w", it'll work because unlike the anatomical data, where native T1w data doesn't use "space-T1w" in the file name, the functional data *does* have "space-T1w" in its file name - therefore it can be correctly parsed by pyBIDS! *** **Q** Well, might as well ask here: What's a good resource to be in touch with the neuroimaging community? For example Hadley Wickham's book, Oxford Handbook for Medical Statistics, Rbloggers and STDHA websites are good places for R and Stats. What are the equivalents in neuroimaging? **A** The neuroimaging equivalent would be Neurostars. You can find it linked under the "Neuroimaging Forum" heading. Also, if you are using software packages hosted on GitHub, asking questions using GitHub issues is also a good place. Lastly, there's a neuroimaging Slack-like platform with different channels to ask questions on specific topics: https://mattermost.brainhack.org *** **Q** I am going through the execise from 02-exploring_fmriprep. Any time that I enter layout.get command it get NameError: name 'layout' is not defined. This is for the first two exercises. When doing the third exercise I have a NameError: name 'func_data' is not defined. What am I missing? I entered the following commands: 1. func_data = layout.get( datatype='func', suffix='preproc', space='T1w') 2. mni_func_data = layout.get(datatype-'func', suffix='preproc', space='MNI152NLin2009cAsym') mni_func_data 3.native_func_data = [b for b in func_data if b not in mni_func_data] native_func_data Thank You, I just re-ran the code before, and it all worked. **A** Did you re-run the code that comes before the exercise section? Anytime you close a notebook all the variables that you generated get lost, you need to re-run the cells from the beginning to re-initialize the variables again. *** **Q** In 04-integration_functional_data_solutions, right after command: func_mni_img.shape it suggests that we try func.slicer[x,y,z] vs/or func.slicer[x,y,z,t] But, I get the error: NameError: name 'func' is not defined Thank You **A** Those are just meant to be illustrative examples of how functional data has 4 indices vs. just 3. The variable "func" is never defined in any of the cells which is why you're getting that error. It works now, thank you. *** **Q** In 06_data-cleaning-with-nilearn, the sectionon Applying confound regression, Method 1 When I run: clean_img = img.clean_img(func_img,confounds=confounds_matrix,detrend=True,standardize=True, low_pass=low_pass,high_pass=high_pass,t_r=t_r, mask_img=mask_file) I get a ValueError, i'm guessing it has to do with "t_r=t_r, mask_img=mask_file)", and again ValueError: "Mask shape: (65, 77, 49) is different from img shape:(65, 77, 5)" More errors show up on next line when using plot.plot..... I'm guessing it could be with the shape/size not matching. **A** I tried running through the solutions notebook and can't reproduce your error. Maybe you mis-specified dropping TRs? i.e: `func_img = raw_func_img.slicer[:,:,:5,:]? ` I can't think of other reasons why the shape of the functional image would have "5" in it's third dimension. *** **Q** Just to make sure, for submitting the assignment, may we upload the Jupyter notebook into the Assignment Dropbox section on our Scinet account? **A** Yes you can download the notebook as a PDF then upload that as the file! *** **Q** Hi, somewhat off topic of the assignment, but I'm interested in running fmriprep on a large sample and was wondering if you could link any code to run it in parallel on SciNet? I have already created the singularity image and bids converted my files. Thanks! **A** Here's an example from Erin: https://github.com/edickie/bids-on-scinet/blob/master/examples/sbatch_fmriprep1.1.2_anat_p08.sh We may have more examples, stay posted...! *** For anyone having issues with getting files for notebook 4 copy and paste this block below: ``` fmriprep_dir = '../data/ds000030/derivatives/fmriprep/' layout=BIDSLayout(fmriprep_dir, validate=False) T1w_files = layout.get(subject='10788', datatype='anat', suffix='preproc', space='MNI152NLin2009cAsym',return_type='file') brainmask_files = layout.get(subject='10788', datatype='anat', suffix='brainmask', space='MNI152NLin2009cAsym',return_type='file') func_files = layout.get(subject='10788', datatype='func', suffix='preproc', space='MNI152NLin2009cAsym',return_type='file') func_mask_files = layout.get(subject='10788', datatype='func', suffix='brainmask', space='MNI152NLin2009cAsym',return_type='file') ``` ***

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully