Hackpads are smart collaborative documents. .

Marianne Reddan

280 days ago
Unfiled. Edited by Marianne Reddan 280 days ago
  • INTERNAL PROCEDURES
 
  • tor_3d.m, canlab_results_fmridisplay.m,  addblobs.m (a function of a fmridisplay object)
 
280 days ago
Unfiled. Edited by Marianne Reddan 280 days ago
Marianne R CANLab Repository Guide Meeting Notes
 
 
Reminders:
**please remember to link to relevant wiki pages.
**ba$h tips can later be moved to margins in relevant sections
**backup this hackpsad after each meeting: http://hackpadtopdf.com
--------
Upcoming meetings:
  1. TBA                                                 
--------
Progress Updates:
Jessica M
  • Questions for Tor: 
  • Why should the plots of the contrast images in group level output be normally distributed?
Marianne R
  • Does a whole brain multilevel mediation use the mask to crop data out before the analysis, or is the analysis performed on every voxel, but then cropped to the mask during display only?
  • MB preproc questions: 
  • hpf cut off still 180?
  • microonset time & microtime resolution? there's not slice timing...
  • time mod on?
  • MRN doesnt preproc the structural?
  • GLM dsgn q's
  • are runs concatenated before or after condition specification
  • are pmods treated at conditions when specifying singletrial mode
  • Future Topics
mediation toolbox, predict toolbox, how to plot outputs, database of data quality, object oriented tools (create for preproc), work on nipy pipeline for preproc, clean up this existing document & have someone use & rate for clarity & flexibility, start stackoverflow & git
--------
Agenda Items:
  • general:
  • get documentation / steps for using the object oriented tools
  • clean up existing sections & grade clarity/quality
  • add a "common problems" section to each topic for troubleshooting
  • test inrealign
  • use pain prediction data set to run through, ease pipeline alterations
  • document steps for robust_nonparam_*
  • theoretical information on bootstrapping for mediation
  • glm code:
  • canlan_glm_publish isn't flexible for runs with unequal amounts of events -- won't pop out VIF graphs
  • better labeling for contrast images in glm_publish output html file (currently puts name of the next starting contrast directly below the image of the previous contrast)
  • colors in the threshold legend suck
  • use neurosynth nsviewer for group level output of contrast maps so that it is interactive and the thresholding can be changed
  • luka has a wrapper to do this in fslview -- add to this hackpad & to the wiki
  • preproc code:
  • add contour plot to coreg preproc output plots
  • build NiPy Pipeline to test out the different preproc options (i.e. no slicetime,etc)
  • add option for skull stripping?
  • resolve issue of error for too long functional image names?
  • make use of canlab_qc_metrics1 in the preproc output
  • save the rssd movies from preproc somewhere
  • fix preproc output figures to have white backgrounds (to see the scales) & clear labels
  • fix implicit mask error in canlab_preproc_2012 (failure to move file)
  • clarify behind the scenes work in preproc (motion corr, slice time, smoothing functions, etc)
  • To enhance co-reg check: could turn functional image into contour plot, super impose it on a better brightness/contrasted struc image of that subject, so coreg can be more accurately assessed visually.. mean image data & use contour command to make the plot (look at code for adding blobs according to coorindates fmri display object add blobs function (could tweak this to make contour plot of whole image not just the blobs) -->  canlab_results_fmridisplay --> fmridisplay addcontours as an option
  • add canlab_qc_metrics1.m to preproc scripts,
  • preproc --> options to add: no slice timing correction, successive diff movies
DSGN files
  • add single trial model struc to the example DSGN file
--------
 
 
862 days ago
Unfiled. Edited by Marianne Reddan 862 days ago
Marianne R preproc_part1
A detailed look at step one of the CANLab preprocessing script.
  • Inputs & Outputs
  • [preprocessed_files mean_image_name] = preproc_part1(PREPROC,  ['slice timing', 0|1], ['motion correction', 0|1], ['local', 0|1], ['verbose', 0|1], ['clean_up', 0|1], ['save plots', 0|1], ['SPM2' | 'SPM5'], ['movie', 0|1], ['mean func', 0|1], ['run_dir_base', subpath])
Inputs
  • Required
  • PREPROC
  • a structure containing:
  • .func_files 
  • a cellstr of Nifti .nii or Analyze .img files containing the data
  • .TR
  • repeat time of scanner (essentially, time between each 3d volume)
  • .num_vols_per_run: vector of the number of 3d volumes in each run. This does NOT include acquisition scans discarded with DISDAQS
  • Looks like you have to remove
  • .spm_ver: 
  • [OPTIONAL]
  • 'SPM2' or 'SPM5' (default: 'SPM5')
  • .run_dir_base: 
  • [OPTIONAL] 
  • string of a subpath (or full path) under each subject's directory to place the functional files (default: '')
  • Optional Flags
  • slice timing 
  • boolean for whether or not to perform timing acquisition correction (default: 1)
  • motion correction 
  • boolean for whether or not to perform motion correction (default: 1)
  • local 
  • boolean for whether or not to copy files locally, operate, and then copy back (default: 0)
  • verbose 
  • boolean for whether or not to display the shell commands (default: 0)
  • clean_up 
  • boolean for whether you want to get rid of intermediate images and data files that are not necessary later (default: 1), like:
  • delete_ana_imgs('ravols.img')
  • save plots 
  • boolean for saving plots of the results of various stages (default: 1)
  • SPM version
  • flag to indicate which method to use (default: 'SPM8') - supercedes PREPROC.spm_ver
  • movie 
  • boolean for whether or not to make an .avi movie of the middle slice (default: 0)
  • mean func 
  • boolean for whether or not to make a mean image of all the functional images (default: 0)
  • acquisition 
  • order of slice image acquisition
  • default: interleaved, bottom up
Basic Steps
  1. Performs slice timing correction using the function:
  • spm8_timing_correction
  • this creates 'a_files' to be stored in PREPROC.slice_time_corr_func_files
  1. Performs motion correction using:
  • spm8_motion_correction
  • makes [r_files, mvmt_param_files] and saves them in:
  •     PREPROC.realigned_func_files = r_files;  
  •     PREPROC.mvmt_param_files = mvmt_param_files;
  • Note:  fsl_motion_correction is an option
  1.  Performs outlier identification?
  •  scnlab_outlier_id
  1.  Computes global image value
  • tor_global
  • mean_image
 
777 days ago
Unfiled. Edited by Marianne Reddan 777 days ago
Marianne R CANLab Repository Guide - Backup
saved 06/05/15
Mission: To provide a guide that holds your hand through all the steps of CANLab data analyses, and provides a brief theoretical motivation for each step. 
--------
This document is maintained by Marianne Reddan.
Contact: marianne.reddan@colorado.edu
--------
Reminders:
**please remember to link to relevant wiki pages.
**ba$h tips can later be moved to margins in relevant sections
**backup this hackpsad after each meeting: http://hackpadtopdf.com
--------
Upcoming meetings:
  1. MultiBand Preprocessing Series:
  1. On the agenda and SNR
  1. Mini-Hackathon Monday 2/16, 3-4:45pm
  1. Add your suggestions!  
  1. PCA with Anjali                                                        
--------
Progress Updates:
Jessica M
  • Questions for Tor: 
  • Why should the plots of the contrast images in group level output be normally distributed?
Marianne R
  • Does a whole brain multilevel mediation use the mask to crop data out before the analysis, or is the analysis performed on every voxel, but then cropped to the mask during display only?
  • MB preproc questions: 
  • hpf cut off still 180?
  • microonset time & microtime resolution? there's not slice timing...
  • time mod on?
  • MRN doesnt preproc the structural?
  • GLM dsgn q's
  • are runs concatenated before or after condition specification
  • are pmods treated at conditions when specifying singletrial mode
  • Future Topics
mediation toolbox, predict toolbox, how to plot outputs, database of data quality, object oriented tools (create for preproc), work on nipy pipeline for preproc, clean up this existing document & have someone use & rate for clarity & flexibility, start stackoverflow & git
--------
Agenda Items:
  • general:
  • get documentation / steps for using the object oriented tools
  • clean up existing sections & grade clarity/quality
  • add a "common problems" section to each topic for troubleshooting
  • test inrealign
  • use pain prediction data set to run through, ease pipeline alterations
  • document steps for robust_nonparam_*
  • theoretical information on bootstrapping for mediation
  • glm code:
  • canlan_glm_publish isn't flexible for runs with unequal amounts of events -- won't pop out VIF graphs
  • better labeling for contrast images in glm_publish output html file (currently puts name of the next starting contrast directly below the image of the previous contrast)
  • colors in the threshold legend suck
  • use neurosynth nsviewer for group level output of contrast maps so that it is interactive and the thresholding can be changed
  • luka has a wrapper to do this in fslview -- add to this hackpad & to the wiki
  • preproc code:
  • add contour plot to coreg preproc output plots
  • build NiPy Pipeline to test out the different preproc options (i.e. no slicetime,etc)
  • add option for skull stripping?
  • resolve issue of error for too long functional image names?
  • make use of canlab_qc_metrics1 in the preproc output
  • save the rssd movies from preproc somewhere
  • fix preproc output figures to have white backgrounds (to see the scales) & clear labels
  • fix implicit mask error in canlab_preproc_2012 (failure to move file)
  • clarify behind the scenes work in preproc (motion corr, slice time, smoothing functions, etc)
  • To enhance co-reg check: could turn functional image into contour plot, super impose it on a better brightness/contrasted struc image of that subject, so coreg can be more accurately assessed visually.. mean image data & use contour command to make the plot (look at code for adding blobs according to coorindates fmri display object add blobs function (could tweak this to make contour plot of whole image not just the blobs) -->  canlab_results_fmridisplay --> fmridisplay addcontours as an option
  • add canlab_qc_metrics1.m to preproc scripts,
  • preproc --> options to add: no slice timing correction, successive diff movies
DSGN files
  • add single trial model struc to the example DSGN file
--------
  • INTERNAL PROCEDURES
GETTING STARTED WITH BLANCA
What To Know More? Check the wiki
  • Log in
eehitchcock@gmail.com
Marianne R
  • If you cannot access /work/ics you need to email rc-help@colorado.edu and cc Tor and ask:
  • Could you give me permissions to towa7957grp and access to /work/ics?
  • Do you have one of those cool key fobs? You'll need it. Contact OIT if not.
  • ssh YOURIDENTIKEY@blogin01.rc.colorado.edu
  • Password is your 4 digit pin followed by whatever series of numbers appears when you click that button
  • save blanca as an alias so you type less in the future:
  • emacs .bash_profile
  • at the bottom of that add:
  • alias blancalogin='ssh mare8532@blogin01.rc.colorado.edu'
  • CNTRL+ XS to save
  • CNTRL+ XC to quit emacs editor
  • now you can just type in blancalogin to get in in the future
  • How to talk to Blanca
  • Start terminal directly in the eye, and type something in:
  • torque
  • Moab, or 
  • Slurm
  • slurm is now the only blanca language
  • Configuring your Blanca
  • this is on the wiki
  • edit your bash profile
  • emacs my.bashrc
  • paste all of this stuff in:
  • NOTE: R module removed because Blanca can't locate it.
  • export MODULEPATH=$MODULEPATH:/projects/ics/modules
  • module add torque/torque-default-blanca
  • module add moab/moab-7.1.3
  • module add matlab/matlab-2014a
  • module add fsl/5.0.2.2
  • module add spm/spm8_r5236
...
862 days ago
Unfiled. Edited by Marianne Reddan 862 days ago
preproc_part2
Marianne R Goal: Performs co-registration, normalization, and smoothing. It takes images from realignment (ravols) to smoothed, normalized functions (swravols).
  • Inputs & Outputs
  • preproc_part2(PREPROC2, ['set_origins', 0|1], ['warp', 0|1], ['smooth', 0|1], ['check norms', 0|1], ['SPM2' | 'SPM5'], ['wh_subjs', n], ['coreg anat to func', 0|1], ['generate mean', 0|1], ['verbose', 0|1], ['clean up', 0|1], ['save plots', 0|1])
Inputs
  • PREPROC2 is a structure containing these fields:
  • .anat_files 
  • cellstr of subjects' anatomical images
  • .files_to_warp  
  • cell array of cellstrs of subjects' functional images or result images (also falls back to .ra_func_files)
  • .mean_ra_func_files 
  • cellstr of subjects' mean prewarped functional images
  • Optional PREPROC2 fields:
  • .inplane_files 
  • cellstr of subjects' T1 images with the same number of slices as a functional image, but much higher resolution within the slice - useful as an intermediate image, but not required
  • .templ 
  • canonical image to warp to - (default: avg152T1.nii);
  • .spm_ver
  • 'SPM2' or 'SPM5' - (default: SPM8)
  • Other parameters
  • wh_subjs 
  • vector of numbers indicating which subjects to preprocess (default: all subjects)
  • set_origins 
  • set origins of images (default: 1)
  • warp 
  • set normalization of functional images (default: 1)
  • smooth 
  • set smoothing of functional images (default: 1)
  • check_norms 
  • check the fitness of the normalization (default: 0) this is better run separately, after all preprocessing is done
  • coreg anat to func 
  • coregister the anatomical image too the mean func (default: 1)
  • don't turn this off unless you know for a fact they're already coregistered; if in doubt, leave on
  • generate mean 
  • generate mean wra img (default: 1)
  • meaningless if warping result images (e.g., con*nii, spmT*nii, beta*nii, etc)
 
 
864 days ago
Unfiled. Edited by Marianne Reddan 864 days ago
canlab_glm_README.txt
Marianne R
  • OVERVIEW
  • canlab_glm_* are a set of functions to handle the running
  • of glm analyses of fmri data. They use SPM for analysis of
  • individual subjects and Tor Wager's robust regression
  • functions (robfit) for group level analysis. Details can
  • be found in the description of the DSGN structure (below) 
  • and in the help statements for the functions, but here is a brief
  • overview:
  •  
  • Before running canlab_glm functions, you will need to have:
  • - preprocessed functional data
  • - modeling files (SPM style "conditions" and "regressors" MAT-files)
  • - a DSGN structure loaded in your workspace or saved as a MAT-file
  •  
  •  
  • PREPROCESSING
  • You can use canlab_preproc_2012 for your preprocessing needs. Whatever 
  • you use, you must end up with 4D functional image files that have the
  • same name for each subject and the relative path to each subject's directory.
  • See DSGN.funcnames
  •  
  •  
  • SPM "REGRESSORS"
  • A simple script can make multiple regressors files, one 
  • for each run, from the products of canlab_preproc_2012
  • (several wagerlab studies have used modified version of the same 
  • script, make_noise_model1.m, for this purpose). If needed, you
  • can also include regressors of interest in your multiple regressors
  • files. You can also save multiple files and call a different one
  • for each analysis you run.
  • See DSGN.multireg
  •  
  •  
  • SPM "CONDITIONS"
  • Similarly, you must make conditions files, typically using
  • data in your experiment logs (e.g., .edat files from E-Prime).
  • This is often the most complicated process in running an
  • analysis and varies the most from one experiment to the next.
  • See DSGN.contrasts
  •  
  •  
  • LOWER LEVELS IN SPM
  • With these files in place, you will then need to assemble a
  • DSGN structure (probably using a script) that will be passed into 
  • canlab_glm_subject_levels (defines all aspects of the design/model
  • for the analysis).
  •  
  • canlab_glm_subject_levels will take DSGN as a
  • variable (from the workspace) or as a MAT-file, so your setup
  • script can either save DSGN in a MAT-file or simply load the
  • DSGN variable into the workspace.
  •  
  • Ex:
  • >> setup_pr_model2
  • >> canlab_glm_subject_levels(DSGN, 'email', 'ruzic@colorado.edu')
  • OR (if saved as a MAT-file)
  • >> canlab_glm_subject_levels('pr_model2.mat')
  •  
  • Make sure you check out the available options in 
  • help canlab_glm_subject_levels.
  •  
  • SINGLE TRIAL MODELS
  • In your DSGN file, add:
  • DSGN.singletrials{1}={1 1 0 0}; Where the number of entries in the array is
  • equivalent to the number of conditions in your DSGN file. You indicate with
  • a 1 if you want that condition to be modeled as single trials. 0 will not.
  •  
  • GROUP LEVELS WITH ROBFIT
  • With subject levels completed, you can run group levels with
  • robfit using canlab_glm_group_levels. This function is built
  • with defaults that can be overridden. If you did lower levels
  • using canlab_glm_subject_levels, you can reuse the DSGN structure
  • (or MAT-file containing it).
  •  
  • >> canlab_glm_group_levels(DSGN, 'o', '../second_level/pr_model2')
  •  
  • (By default it the output will be written to the same
  • directory as the subject level analyses. The standard
  • wagerlab organization is to keep group level analyses
  • together in a separate directory, "second_level", hence
  • the 'o' option in the above command.)
  •  
  • Make sure you check out the available options in 
  • help canlab_glm_subject_levels.
 
 
864 days ago
Unfiled. Edited by Marianne Reddan 864 days ago
canlab_glm_dsgninfo.txt
Marianne R
  • %DSGN STRUCTURE
  • %This is the structure variable used by canlab_glm_subject_levels to define an analysis.
  • %(note: optional fields/fields with defaults may be left undefined)
  •  
  •  ________________________________________________________________________________
  • | DSGN.metadata                                     |
  • |   a fieldname for the user to use as desired (typically for annotation).     |
  • |   EX: DSGN.metadata.notes = 'this design uses a modified HRF from model 4';     |
  • |________________________________________________________________________________|
  •  ________________________________________________________________________________
  • | DSGN.modeldir                                     |
  • |   a path (absolute preferred) to the directory holding the subject         |
  • |     level analyses                                 |
  • |   EX: DSGN.modeldir = '/data/projects/wagerlab/current/labdata/ilcp/Imaging/analyses/first_level/model1';
  • |________________________________________________________________________________|
  •  
  •  ________________________________________________________________________________
  • | DSGN.subjects                                     |
  • |   cell array of subject directories (absolute paths)                 |
  • |   EX: DSGN.subjects = filenames('../ilcp[0-9]*','absolute');             |
  • |   EX: DSGN.subjects = importdata('good_subs.txt');                 |
  • |________________________________________________________________________________|
  •  
  •  ________________________________________________________________________________
  • | DSGN.funcnames                                 |
  • |   cell array of strings that specify location of 4D functional data         |
  • |     files within subject directories (may include wildcards)             |
  • |   EX: DSGN.funcnames{1} = 'Functional/Preprocessed/r1/task.nii';         |
  • |   EX: DSGN.funcnames{1} = 'Functional/Preprocessed/*/run*.nii';         |
  • |   (note: the resulting ordering of functional files determines the         |
  • |          session order--must coincide with DSGN.conditions)             |
  • +-- OPTIONAL FIELDS -------------------------------------------------------------+
  • | - DSGN.allowmissingfunc  (DEFAULT: false)                     |
  • |     if true, allow functional files to be missing                 |
  • | - DSGN.concatenation  (DEFAULT: none)                            |
  • |     cell array of arrays of runs to concatenate                 |
  • |     (sparse: unconcatenated runs need not be specified)             |
  • |     EX: DSGN.concatenation = {[1 2] [6:10]}                       |
  • |         this will concatenate runs 1 and 2, 6-10, and leave 3-5 separated     |
  • |     concatenation procedure includes:                         |
  • |       - concatenation of functional data (DSGN.funcnames)             |
  • |         (NOTE: if DSGN.allowmissingfunc is set, each DSGN.funcnames cell     |
  • |                must match no more than one file)                           |
  • |       - concatenate conditions (DSGN.conditions)                 |
  • |         (NOTE: it is assumed that concatenated runs each have the same      |
  • |                conditions in same order)                                    |
  • |       - merge regressors in block diagonal fashion (DSGN.multireg)         |
  • |       - add intercept regressors for all but one run in each concatenation     |
  • |           (one left out because SPM still includes intercept for session)     |
  • |       - add linear trend regressors for each run in concatenation         |
  • | - DSGN.customrunintercepts                             |
  • |     Note: This will only have an effect if using DSGN.convolution         |
  • |     cell array of vectors specifying custom intercepts             |
  • |     one cell per intercept, numbers in vectors specify runs to include in      |
  • |       intercept regressor. (refer to pre-concatenation run numbers)            |
  • |     keep in mind that SPM will assign an intercept regressor to each "session" |
  • |       (where a session is a run or, when using DSGN.concatenation, a          |
  • |       concatenation of runs). It's important to avoid rank deficiency!     |
  • |     when using this option, no intercepts will be added by DSGN.concatenation  |
  • |     EX: If you have 8 runs, you're concatenating them all, but you want session|
  • |        intercepts for the first 4 and last 4 runs + leftover run intercepts:   |
  • |        DSGN.concatenation = [1:8];                                                |
  • |        DSGN.customrunintercepts = {2 3 4 1:4 6 7 8};                  |
  • |        This will create 8 intercepts: one each for runs 2 3 4 6 7 and 8, one      |
  • |          for runs 1-4, and one (added by SPM) for runs 1-8                      |
  • |________________________________________________________________________________|
  •  
  •  ________________________________________________________________________________
  • | DSGN.tr        repetition time (or "TR") of functional data (in seconds))     |
  • | DSGN.hpf       high pass filter (in seconds)                           |
  • | DSGN.fmri_t    microtime resolution (DEFAULT: 16)                 |
  • |   should be left at default unless TR is quite long                 |
  • | DSGN.fmri_t0   microtime onset                                  |
  • |   must correspond to reference slice used in slice time correction         |
  • |________________________________________________________________________________|
  •  
  •  ________________________________________________________________________________
  • | DSGN.conditions                                 |
  • |   cell array (one cell per session) of cell arrays (one cell per         |
  • |     condition) of MAT-file names (acceptable wildcards: [] {} ? *)         |
  • |   each MAT-file contains one or more conditions specified SPM-style (see below)|
  • |   if only one session is specified, it will be applied to all sessions     |
  • |   location of MAT-files: see DSGN.modelingfilesdir (see below)         |
  • |   EX: DSGN.conditions{2} = {'heat' 'rate'};                          |
  • |      if the 2nd functional file is .../r2/swraPAINTASK.nii, then this         |
  • |        will add the conditions defined in:                            |
  • |        .../r2/DSGN.modelingfilesdir/heat.mat                     |
  • |        .../r2/DSGN.modelingfilesdir/rate.mat                     |
  • |   NOTE: all timing is in seconds (not TRs)                            |
  • |                                                             |
  • |   Example SPM-style condition:                                   |
  • |     name{1}     = 'heat';                             |
  • |     onset{1}    = [16.97 54.84 98.57 138.25 179.95];                  |
  • |     duration{1} = [10.75 11.25 11.00  11.75  11.50];                  |
  • |     (See spm fmri -> help -> spm.stats.fmri_spec -> pages 5-10)         |
  • +-- OPTIONAL FIELDS -------------------------------------------------------------+
  • | - DSGN.pmods  (DEFAULT: no pmods)                         |
  • |     cell array (one cell per session) of cell arrays (one cell per condition)     |
  • |       of cell arrays (one cell per modulator) of MAT-file names             |
...

Contact Support



Please check out our How-to Guide and FAQ first to see if your question is already answered! :)

If you have a feature request, please add it to this pad. Thanks!


Log in