This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nipype.pipeline.engine as pe | |
from nipype.interfaces.utility import Function | |
def Hello(): | |
import os | |
from nipype import logging | |
iflogger = logging.getLogger('interface') | |
message = "Hello " | |
iflogger.info(message) | |
return message |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'lampe' | |
""" | |
============================================= | |
1. Registration of T1 to QSM | |
2. Apply the xfm to the masks that have been created with the T1, so they are in QSM space | |
============================================= | |
Packages and Data Setup | |
======================= | |
Import necessary modules from nipype. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nilearn.plotting.img_plotting import plot_img | |
import pylab as plt | |
import nibabel as nb | |
import numpy as np | |
nii = nb.load("/home/raid3/gorgolewski/Downloads/fmap_field_masked.nii.gz") | |
print nii.get_affine() | |
scaling_affine = np.array([[-3, 0, 0, 0], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [4]: !cat /tmp/stefan.py | |
out_name = "/tmp/bla" | |
out = open(out_name, 'w') | |
out.write("asdfasdfasdf\n") #out_str) out.close | |
out = open(out_name, 'w') | |
out.write("asdfasdfasdf\n") | |
out.close() | |
In [5]: %run /tmp/stefan.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(devel)adenauer:~$ cd /tmp/ | |
(devel)adenauer:/tmp$ git clone https://github.com/nipy/nipype.git | |
Cloning into 'nipype'... | |
remote: Reusing existing pack: 36611, done. | |
remote: Total 36611 (delta 0), reused 0 (delta 0) | |
Receiving objects: 100% (36611/36611), 17.80 MiB | 1.13 MiB/s, done. | |
Resolving deltas: 100% (22184/22184), done. | |
(devel)adenauer:/tmp$ cd nipype/ | |
(devel)adenauer:/tmp/nipype$ git remote | |
origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_tr_and_sliceorder(dicom_files, convention="SPM"): | |
import numpy as np | |
import dcmstack, dicom | |
my_stack = dcmstack.DicomStack() | |
for src_path in dicom_files: | |
src_dcm = dicom.read_file(src_path) | |
my_stack.add_dcm(src_dcm) | |
nii_wrp = my_stack.to_nifti_wrapper() | |
if convention == "french": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def partial_correlation_via_inverse(X): | |
model = GraphLassoCV() | |
model.fit(X) | |
prec_ = model.precision_ | |
return -cov2corr( model.precision_ ) ) | |
def cov2corr( A ): | |
""" | |
covariance matrix to correlation matrix. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#merge maps - condition 1 | |
fslmerge -t "/scr/adenauer1/workingdir/rs_analysis_group/main_workflow/merge_conn_maps_6_58_0/roi_6_58_0_masked_merged.nii.gz" /scr/namibia1/baird/MPI_Project/results/volumes/normalized_z_scored_corr_map/_subject_id_13261.8d/_roi_6.58.0/_fwhm_5/roi_6_58_0_masked.nii /scr/namibia1/baird/MPI_Project/results/volumes/normalized_z_scored_corr_map/_subject_id_14390.d3/_roi_6.58.0/_fwhm_5/roi_6_58_0_masked.nii /scr/namibia1/baird/MPI_Project/results/volumes/normalized_z_scored_corr_map/_subject_id_14446.fb/_roi_6.58.0/_fwhm_5/roi_6_58_0_masked.nii /scr/namibia1/baird/MPI_Project/results/volumes/normalized_z_scored_corr_map/_subject_id_16090.c9/_roi_6.58.0/_fwhm_5/roi_6_58_0_masked.nii /scr/namibia1/baird/MPI_Project/results/volumes/normalized_z_scored_corr_map/_subject_id_12184.55/_roi_6.58.0/_fwhm_5/roi_6_58_0_masked.nii /scr/namibia1/baird/MPI_Project/results/volumes/normalized_z_scored_corr_map/_subject_id_15070.25/_roi_6.58.0/_fwhm_5/roi_6_58_0_masked.nii /scr/namibia1/baird/MPI_Projec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Process: Python [6691] | |
Path: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python | |
Identifier: Python | |
Version: 2.7.3 (2.7.3) | |
Code Type: X86-64 (Native) | |
Parent Process: Python [6670] | |
User ID: 501 | |
Date/Time: 2012-09-27 19:40:00.297 +0200 | |
OS Version: Mac OS X 10.8.2 (12C54) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_coregistration(): | |
anat_file = "/Users/filo/data/rs_pipeline/GSDT/anat/mprage.nii" | |
func_file = "/Users/filo/workdir/rs_preprocessing/preprocess/preproc/take_mean_art/weighted_mean/corr_rest_roi_dtype.nii.gz" | |
affine_file = '/Users/filo/workdir/rs_preprocessing/preprocess/preproc/getmask/register/mapflow/_register0/corr_rest_roi_dtype_bbreg_recon_all.mat' | |
from nipy.labs import viz | |
from nipy.labs.viz_tools import anat_cache | |
import nibabel as nb | |
anat = nb.load(anat_file).get_data() | |
anat_affine = nb.load(anat_file).get_affine() |