Skip to content

Instantly share code, notes, and snippets.

/* Copyright (c) 2008-2022 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Covered Software is provided under this License on an "as is"
* basis, without warranty of any kind, either expressed, implied, or
* statutory, including, without limitation, warranties that the
* Covered Software is free of defects, merchantable, fit for a
@maxpietsch
maxpietsch / mrregister_linear_init.sh
Last active September 22, 2021 10:55
demonstration of mrregister's linear initialisation using diagnostics images
#!/usr/bin/env bash
set -x
tmp_dir=$(mktemp -d -t mrregister_init-XXXXXXXXXX)
cd $tmp_dir
echo $tmp_dir
# ____ 0. get DWI data and create two ODFs ____
for sub in sub-02 sub-03; do
wget --quiet https://github.com/MRtrix3/script_test_data/raw/master/BIDS/"${sub}"/dwi/"${sub}"_dwi.bval
#!/usr/bin/env python
def usage(cmdline):
cmdline.set_author('Max Pietsch')
cmdline.set_synopsis('Landmark-based manual alignment')
cmdline.add_description('Calculates the rigid transformation between two images based on three or more matching landmarks.')
cmdline.add_argument('fixed', help='The reference input image')
cmdline.add_argument('moving', help='The moving input image')
cmdline.add_argument('rigid', help='The output transformation')
@maxpietsch
maxpietsch / is_valid_id.py
Created November 19, 2020 14:25
check dHCP subject ID for validity.
#! /usr/bin/env python3
# check subject ID for validity.
usage="""
usage:
is_valid_id.py <dhcp_subject_id>
example: ./is_valid_id.py CC01253XX08
@maxpietsch
maxpietsch / dwiqc.py
Last active October 13, 2020 15:43
generate screenshots for QC report
#!/usr/bin/env python
#
# generate screenshots for QC report
#
#
# Author: Max Pietsch
# King's College London
# maximilian.pietsch@kcl.ac.uk
#
@maxpietsch
maxpietsch / subject_tck_in_template_space.sh
Last active December 27, 2022 12:00
generate and warp subject streamlines to template space
#/bin/env bash
do_nonlinear_registration=false
tmp_dir=$(mktemp -d -t tcktransform-XXXXXXXXXX)
cd $tmp_dir
# ____ 0. get DWI data and create two ODFs ____
for sub in sub-02 sub-03; do
wget --quiet https://github.com/MRtrix3/script_test_data/raw/master/BIDS/"${sub}"/dwi/"${sub}"_dwi.bval
#!/usr/bin/env python3
# tool to visualise angular and l=0 dependency of multiple MRtrix3 response functions
# Author: Maximilian Pietsch
import argparse
import numpy as np
from scipy.special import sph_harm
import matplotlib.pyplot as plt
@maxpietsch
maxpietsch / vectorreorient.cpp
Created July 3, 2020 15:39
reorient vector field after transformation
/* Copyright (c) 2008-2020 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Covered Software is provided under this License on an "as is"
* basis, without warranty of any kind, either expressed, implied, or
* statutory, including, without limitation, warranties that the
* Covered Software is free of defects, merchantable, fit for a
@maxpietsch
maxpietsch / add_mrview_app.sh
Created June 25, 2019 08:34
macos mrview as applicatio
#!/usr/bin/env bash
APP=mrview
mkdir -vp ${APP}.app/Contents/MacOS ${APP}.app/Contents/Resources
PATH="$PATH:/usr/libexec" # PlistBuddy in PATH
printf '#!/usr/bin/osascript\ntell application "Terminal"\n\tactivate\n\tdo script "mrview; exit"\nend tell\n' > ${APP}.app/Contents/MacOS/${APP}
chmod +x ${APP}.app/Contents/MacOS/${APP}
PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleDisplayName string ${APP}"
PlistBuddy ${APP}.app/Contents/version.plist -c "add ProjectName string ${APP}"
This file has been truncated, but you can view the full file.