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 / mem_fingerprint.py
Last active November 28, 2017 06:07
Comparing python interfaces vs. Report Capable.
>>> from pympler import asizeof
... from nipype.interfaces.fsl import BET
... from niworkflows.interfaces.masks import BETRPT
... from nipype.pipeline import engine as pe
... from niworkflows.nipype.pipeline import engine as pe2
>>> bet_old = BET(in_file="/home/oesteban/Data/openfmri/ds000001/sub-01/anat/sub-01_T1w.nii.gz")
>>> bet_rpt = BETRPT(in_file="/home/oesteban/Data/openfmri/ds000001/sub-01/anat/sub-01_T1w.nii.gz", generate_report=True)
>>> asizeof.asizeof(bet_old)
3808
@oesteban
oesteban / output.txt
Created November 21, 2017 23:46
Crashing nipype with memory consumption
Top 1 lines
#1: traits/has_traits.py:3008: 1.3 KiB
if not meta_eval( getattr( trait, meta_name ) ):37 other: 14.1 KiB
Total allocated size: 15.3 KiB
Top 1 lines
#1: testnipype.py:50: 8388608.0 KiB
large_str = ' ' * (8 * 1024**3)94 other: 362.5 KiB
Total allocated size: 8388970.6 KiB
@oesteban
oesteban / check_jobs.py
Last active December 18, 2017 19:32
Check for a job-array in SLURM
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import re
import datetime
import subprocess as sp
from textwrap import indent
def get_parser():
@oesteban
oesteban / fix_slicetiming.py
Last active June 12, 2020 20:46
fixing slicetiming in all sidecar jsons
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from glob import glob
import numpy as np
import json
import datalad
files = glob('sub-*/func/*_bold.json')
@oesteban
oesteban / IEEEbib.bst
Created October 20, 2017 23:42
The BST file for IEEE conferences, sorting names
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IEEE.bst %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bibliography Syle file for articles according to IEEE instructions
% [email protected] <22-JUN-93>
% modified from unsrt.bib. Contributions by Richard H. Roy
ENTRY
{ address
author
booktitle
chapter
@oesteban
oesteban / mprofile_20170324074440.dat
Created March 24, 2017 17:18
memory_profile trace
This file has been truncated, but you can view the full file.
CMDLINE python mriqc data/ out/ participant --participant_label 50052 --mem_gb 64 --verbose-reports --n_procs 10 --ants-nthreads 68 -f --profile -m T1w
MEM 0.816406 1490359481.9571
MEM 27.171875 1490359485.5077
MEM 28.769531 1490359488.9861
MEM 40.691406 1490359492.4732
MEM 55.683594 1490359495.9580
MEM 67.445312 1490359499.4542
MEM 71.191406 1490359502.9444
MEM 80.781250 1490359506.4395
MEM 86.386719 1490359509.9397
@oesteban
oesteban / warpinfo.rst
Created January 12, 2017 21:16 — forked from satra/warpinfo.rst
combining bbregister, fsl and ants to warp functional images
@oesteban
oesteban / rep_script.py
Last active August 12, 2016 08:10
Fixes docstrings for unicode
#!/usr/bin/env python
import re
import sys
from builtins import open
squote_exp = re.compile(r"(?P<ms>u?'(?:[^'\n\r\\]|(?:'')|(?:\\x[0-9a-fA-F]+)|(?:\\.))*')",
re.UNICODE)
def add_upref(m):
ms = m.group('ms')