Skip to content

Instantly share code, notes, and snippets.

View oesteban's full-sized avatar
🦄

Oscar Esteban oesteban

🦄
View GitHub Profile
# Find native-to-freesurfer transform matrix
tkregister2 --mov out/fmriprep/sub-06/anat/sub-06_T1w_preproc.nii.gz --targ out/freesurfer/sub-06/mri/orig.mgz --reg native2fs.dat --noedit --regheader --s sub-06
# Convert to lta
lta_convert --src out/fmriprep/sub-06/anat/sub-06_T1w_preproc.nii.gz --trg out/freesurfer/sub-06/mri/orig.mgz --inreg native2fs.dat --outlta native2fs.lta --subject sub-06
# Concatenate BOLD-to-native and native-to-freesurfer
mri_concatenate_lta -out_type 1 -subject sub-06 work/fmriprep_wf/single_subject_06_wf/func_preproc_ses_pre_task_rest_run_01_wf/bold_reg_wf/bbreg_wf/bbregister/uni_xform_masked_bbreg_sub-06.lta native2fs.lta bold2fs.lta
# Find native-to-freesurfer transform matrix
tkregister2 --mov out/fmriprep/sub-06/anat/sub-06_T1w_preproc.nii.gz --targ out/freesurfer/sub-06/mri/orig.mgz --reg native2fs.dat --noedit --regheader --s sub-06
# Convert to lta
lta_convert --src out/fmriprep/sub-06/anat/sub-06_T1w_preproc.nii.gz --trg out/freesurfer/sub-06/mri/orig.mgz --inreg native2fs.dat --outlta native2fs.lta --subject sub-06
# Concatenate BOLD-to-native and native-to-freesurfer
mri_concatenate_lta -out_type 1 -subject sub-06 work/fmriprep_wf/single_subject_06_wf/func_preproc_ses_pre_task_rest_run_01_wf/bold_reg_wf/bbreg_wf/bbregister/uni_xform_masked_bbreg_sub-06.lta native2fs.lta bold2fs.lta
@oesteban
oesteban / gifti_surfs.py
Last active February 21, 2018 17:55
GIFTI
import nibabel as nb
from nipype.utils.filemanip import fname_presuffix
def center_surface(in_gifti, newpath=None,
offset_from=['VolGeomC_R', 'VolGeomC_A', 'VolGeomC_S']):
gii = nb.load(in_gifti)
offset = [float(gii.darrays[0].meta.metadata[v]) for v in offset_from]
data = gii.darrays[0].data + offset
meta = gii.darrays[0].meta.metadata
for k in offset_from:
meta[k] = '%f' % 0.0
@oesteban
oesteban / fmriprep.sbatch
Last active April 6, 2024 19:52
Submitting many FMRIPREP/MRIQC tasks in Sherlock
#!/bin/bash
#
#SBATCH -J fmriprep
#SBATCH --array=1-257%7
#SBATCH --time=24:00:00
#SBATCH -n 1
#SBATCH --cpus-per-task=16
#SBATCH --mem-per-cpu=4G
#SBATCH -p russpold,owners,normal
@oesteban
oesteban / bash-tricks.sh
Created August 18, 2018 03:28
Some useful snippets in bash
# Find empty folders starting with ds
for dir in ds*; do [ -z "`find $dir -maxdepth 1 -type f`" ] && echo "$dir is empty"; done
@oesteban
oesteban / BOLD-to-T2w_individual.sh
Last active October 5, 2018 17:27
Work on rodents
antsRegistration -d 3 -m MI[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,1.0,32,Random,0.2] -t Affine[0.01] -c [100x100x100,1.0e-8,25] -s 0.6x0.4x0.2mm -f 2x1x1 -l -x [sub-EMV00017_run-01_T2w_brainmask.nii.gz] -u -v -o ts2_epi0 -a 1
antsRegistration -d 3 -m MI[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,32,Random,0.2] -m CC[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,5,Random,0.2] -t SyN[1,2.0,1.75] -c [200x50,1.0e-8,5] -s 0.4x0mm -f 2x1 -m MI[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,32,Random,0.2] -m CC[sub-EMV00017_run-01_T2w_preproc.nii.gz,time2_hmc_avg_inu.nii.gz,0.5,5,Random,0.2] -t SyN[1,1.0,0.75] -c [200x50,1.0e-8,5] -s 0.6x0.2mm -f 2x1 -l -x [sub-EMV00017_run-01_T2w_brainmask.nii.gz] -l -x [sub-EMV00017_run-01_T2w_brainmask.nii.gz] -u -v -o ts2_epiA -a 1 -r ts2_epi0Composite.h5 &> ts2.log
antsApplyTransforms -d 3 -i ~/Data/LC_dfMRI/tpl-Schwarz/tpl-Schwarz_rois.nii.gz -r time2_hmc_avg_inu.nii.gz -o time2_rois.
@oesteban
oesteban / mriqc_webapi_ratings.py
Created July 23, 2019 16:37
Pull the ratings associated to a given MD5 checksum.
from os import getenv
from pathlib import Path
from json import load
import urllib.request, json
import pandas as pd
def get_rating(checksum):
"""
Grab the latest rating found for a given MD5 checksum.
@oesteban
oesteban / Makefile
Created December 26, 2019 08:21 — forked from jakevdp/Makefile
Test of specializing sphinx autodoc
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
@oesteban
oesteban / FD test.ipynb
Last active January 30, 2020 20:47
Testing framewise displacement
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oesteban
oesteban / sample_openfmri.py
Created March 23, 2020 02:47
Sample OpenfMRI (scraps from *fMRIPrep*)
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
A tool to sample OpenfMRI datasets using a datalad installation
Please run this first: ::
# install openfmri dataset
datalad install -r ///openfmri