Monday, 4 January 2016

Freesurfer recon-all

https://surfer.nmr.mgh.harvard.edu/fswiki/RecommendedReconstruction

Once all data is downloaded from dougal and transferred to your account (converted to NIFTI or not) you can start to set up the data for reconstruction.

1. Create a subdirectory for your raw data.
2. Create subject data directories with the  following command:

recon-all -i ./SAGA/SAGA01/NIFTI/MPRAGE.nii.gz -subjid NAME_OF_OUTPUT_DIRECTORY

This specifies where to find the raw data, and what to name the new directory. This new directory will be empty except for 001.mgz (raw data), and this is where all processing data will be saved.

Running the reconstruction:

recon-all  -all -subjid NAME_OF_OUTPUT_DIRECTORY



Friday, 21 August 2015

Unix commands

Queue commands

echo 'command1 --option arg1 arg2' | at -q b -m now
echo 'command2 ...' | at -q b -m now

Tuesday, 14 April 2015

TBSS preparation

ExploreDTI to set up files for RA/AD

Open matlab by typing matlab into terminal

Go up in current directory to find the folder ‘exploredti’ then go into it and drag and drop ‘source’ and ‘MainExploreDTI’ into terminal.

Type MainExploreDTI

-          ‘plugins’ – ‘export stuff to *.nii files’ – select ‘multiple’- select ‘FA/largest eigenvalue’-  select ‘MD/Radial/transverse diffusivity’ – ‘ok’
S    Select file containing mat files and then select files to save the files in.


- - This will produce nifti files for the measures that you have selected.

     TBSS


      http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/TBSS/UserGuide


All data should be in NIFTI format and corrected for the effects of eddy current distortions and head motion.

Make directories called 'TBSSmain' and inside that 'mytbss'
Copy FA nifti files into mytbss
Navigate into 'mytbss'

Preprocessing


-    %tbss_1_preproc *.nii
-         % tbss_2_reg -T 
-         %  tbss_3_postreg –S

-          %  tbss_4_prestats 0.2

n    These commands perform a non-linear registration and affine transformation into MNI space using the non-linear registration tool. This creates mean FA and skeletonised images.
S   See TBSS UserGuide for other options.

Freesurfer longitudinal processing stream

https://surfer.nmr.mgh.harvard.edu/fswiki/LongitudinalProcessing

https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/LongitudinalTutorial

1. Cross-sectionally process your data (recon-all)

2. Create template for all timepoints for each subject.

recon-all -base <templateid> -tp <tp1id> -tp <tp2id> ... -all

3. Longitudinally process all timepoints

  recon-all -long <tpNid> <templateid> -all

4. Inspect the base and longitudinal data




Wednesday, 25 March 2015

DTI preparation for TBSS analysis

Before anything else you need to be sure that the data you need (diffusion and T1 images) have all been retrieved from Dougal into /data/blinded and contain no duplicates.
1) LOGIN IN TO ONE OF THE LINUX SERVERS (nanlnx1, nanlnx2,...)
% ssh kxxxxxxx@nanlnx1.iop.kcl.ac.uk
2) ADD THE NBL MODULE (THIS WILL SET UP YOU ENVIRONMENT SO YOU CAN RUN THE PIPELINE COMMANDS)
%  module add /home/k1339392/software/nbl /etc/nblmodule
3) CREATE THE FOLDERS FOR YOUR PROJECT (i.e. DRUM_PROJECT)
% mkdir ~/DRUM_PROJECT
% mkdir ~/DRUM_PROJECT/nandata
% mkdir ~/DRUM_PROJECT/dtidata
% mkdir ~/DRUM_PROJECT/expdtidata
% cd ~/DRUM_PROJECT
% ls
4) GET THE DATA FROM DOUGAL (add new folders with NIFTI data to ./nandata with NIFTI data)
% getnandata /data/blinded/CNSCNSD ./nandata DRUMPILOT01
% ls ./nandata
5) PREPARE DTI DATA FOR PREPROCESSING ( adds *.nii.gz *.bvec *.bval _mask.nii.gz files to ./dtidata). Use -C option if your data was acquired in the old CNS scanner using the 32 directions pulse sequence (i.e. BRCATLAS and MIAMRC projects).
% prepdti -C  ./nandata ./dtidata DRUMPILOT01 DTI_2mm_60B1500_FDA
% ls ./dtidata
6) PREPARE T1 DATA REQUIRED FOR EPI CORRECTION (adds new _T1.nii.gz _T1_mask.nii.gz files to ./dtidata)
% prept  ./nandata ./dtidata DRUMPILOT01 MPRAGE
7) RUN EXPLORE DTI PREPROCESSING SCRIPT (creates new *.mat *_EPI.mat files in ./expdtidata )
SM/EC CORRECTION ONLY
% expdticorr -R  ./dtidata ./expdtidata DRUMPILOT01 _SMEC
% ls ./expdtidata
SM/EC/EPI CORRECTION
% expdticorr -E  -R  ./dtidata ./expdtidata DRUMPILOT01 _EPI
% ls ./expdtidata

The final result will be a new file in ./expdtidata called DRUMPILOT01_[EPI/SMEC].mat. This file can only be opened with ExploreDTI. Using Explore DTI you will be able to generate any kind of diffusion images/maps you need, including of course tractography datasets.


See DTI pipeline document for more detail

Thursday, 5 March 2015

Random freesurfer commands and links

Table of surface areas (Desikan atlas)

aparc2statstable --hemi lh --subjects <list subjects> --tablefile lh.aparc.area.table

Table of thickness values (Desikan Atlas)

aparcstats2table --hemi lh --subjects <list subjects> -meas thickness --parc aparc --tablefile  lh.aparc.stats.thickness.table

Table of cortical volumes (Desikan Atlas)

aparcstats2table --subjects bert ernie fred margaret --parc aparc.a2005s --hemi rh --meas volume --tablefile aparc_stats_rh.txt

Table of subcortical volumes
asegstats2table --subjects bert ernie fred --meas volume --tablefile aseg_stats.txt

or create text file with path of all subjects and 

asegstats2table --subjectsfile=subject_to_write --meas volume --tablefile aseg_stats.txt

Change background of figure to white:
convert -fill white -opaque black <tksurfer_image_black_background>
<new_image_with_white_background>

http://ftp.nmr.mgh.harvard.edu/fswiki/FsTutorial/MorphAndRecon

Command line Group Analysis
https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/GroupAnalysis

Smoothing/qcache command
http://freesurfer.net/fswiki/FsTutorial/QdecGroupAnalysis_freeview

Methods citation
https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferMethodsCitation

Check surfaces
tkmedit your_subject_name wm.mgz rh.white -aux brain.mgz \
tkmedit your_subject_name wm.mgz lh.white -aux brain.mgz
https://surfer.nmr.mgh.harvard.edu/fswiki/BasicReconstruction

Check subcortical segmentation
tkmedit SUBJECT orig.mgz -aux-segmentation aseg.mgz

Explanation of steps of reconstruction
http://ftp.nmr.mgh.harvard.edu/fswiki/FsTutorial/MorphAndRecon


Recon-all descriptions
https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all