Skip to content

Instantly share code, notes, and snippets.

View dangom's full-sized avatar

Daniel Gomez dangom

  • Cambridge, MA
View GitHub Profile
@dangom
dangom / mecombine.py
Last active March 10, 2024 03:20
Optimal echo combination accounting for motion correction
""" Echo combination.
1. Motion correction
2. Compute weights on motion corrected data
3. Apply inverse transform on weights
4. Apply weights on original data to minimize interpolation.
Methods:
For the echo combination, the first echo was motion corrected using ANTs for
rigid transformation. The transforms were subsequently applied to the later
echoes. The mean images of the motion corrected echoes were subsequently used
for estimating a T2star map. Weights for each echo were computed from the T2star
@dangom
dangom / org-roam-weeklies.el
Created February 4, 2021 03:43
Weekly notes for org-roam
;;; org-roam-weeklies.el --- Weekly-notes for Org-roam -*- coding: utf-8; lexical-binding: t; -*-
;;;
;; Copyright © 2020 Jethro Kuan <jethrokuan95@gmail.com>
;; Copyright © 2020 Leo Vivier <leo.vivier+dev@gmail.com>
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
;; Leo Vivier <leo.vivier+dev@gmail.com>
;; URL: https://github.com/org-roam/org-roam
;; Keywords: org-mode, roam, convenience
;; Version: 1.2.3
#! /usr/bin/python
#
# Author: Gaute Hope (gaute.hope@nersc.no) / 2015
#
# based on example from matlab sinc function and
# interpolate.m by H. Hobæk (1994).
#
# this implementation is similar to the matlab sinc-example, but
# calculates the values sequentially and not as a single matrix
# matrix operation for all the values.
@dangom
dangom / registration.sh
Created August 31, 2022 21:01
Registration example
#!/usr/bin/env bash
fixedfile=$1
movingfile=$2
output=$3
antsRegistration --dimensionality 3 --float 0 --verbose 1 \
--output [$output,${output}.nii.gz] \
--interpolation LanczosWindowedSinc \
--winsorize-image-intensities [0.005,0.995] \
;;; to download all abstracts:
;;; parallel wget --no-clobber --no-parent -r "https://submissions.mirasmart.com/ISMRM2022/Itinerary/Files/PDFFiles/{}.html" ::: $(seq -f "%04g" 00 10000)
;;; Make a simple index so I can search through abstracts in emacs
;;; So that other people can use it, I have put this into an index.html and use a js search framework that mimics completing-read.
;;; See for example https://cheatcode.co/tutorials/how-to-implement-client-side-search-with-fuse-js
;;;
;; List and open any file on eww
(defvar ismrm-abstract-dir "/Users/dg/ismrm2022/PROGRAM/")
(defun ismrm--find-abstract-file ()
@dangom
dangom / scanner.sh
Created April 19, 2022 15:26 — forked from andyrbell/scanner.sh
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf
@dangom
dangom / partial_corr.py
Created November 22, 2017 13:57 — forked from fabianp/partial_corr.py
Partial Correlation in Python (clone of Matlab's partialcorr)
"""
Partial Correlation in Python (clone of Matlab's partialcorr)
This uses the linear regression approach to compute the partial
correlation (might be slow for a huge number of variables). The
algorithm is detailed here:
http://en.wikipedia.org/wiki/Partial_correlation#Using_linear_regression
Taking X and Y two variables of interest and Z the matrix with all the variable minus {X, Y},
@dangom
dangom / bart_centos_installer.bash
Last active November 22, 2020 02:57
Install Berkeley Advanced Reconstruction Toolbox without admin rights on a CentOS machine.
#!/bin/bash
# Time-stamp: <2017-07-19 15:06:39 dangom>
# Script for installing BART and dependencies from source on a CentOS machine without admin rights.
# Steps:
# 1. Build OpenBLAS from source to enable support for LAPACKE C API.
# 2. Build FFTW3 from source to enable float32 support (fftw defaults to double precision. BART doesn't)
# 3. Link against Matlab2016, because something changed in Matlab2017 and the BART build breaks.
# 4. Download Cmake >= 3 since cluster ships with old cmake 2.8
@dangom
dangom / matlab_engine_python_3_6.org
Last active May 21, 2020 14:32
Installing matlab-engine on python 3.6

How to install Matlab Engine on Python 3.6

Preparation

If you’ve tried recently to install matlab engine on a Python 3.6, you’ve seen a message saying that the platform is not supported. That doesn’t make any sense, since Python 3.5 is supported, right?

The problem is that Mathworks hardcodes a list with valid versions, I guess to reduce pressure on their customer service in case something goes wrong with untested versions. Well, that doesn’t mean that we shouldn’t be allowed to try it anyway, right?

@dangom
dangom / mm
Created October 24, 2018 13:27
values for ica output
0.016043 0.002221 -0.035477 0.002108 0.021356 0.007767 -0.000762 -0.007581 0.001191 0.021943
0.009563 0.020156 -0.035227 -0.003960 0.010329 -0.036748 0.010542 0.000222 0.001448 0.021009
0.009083 -0.004882 -0.043019 -0.008569 0.005001 0.007674 -0.006975 -0.001861 0.008550 0.019023
0.004607 -0.002042 -0.044749 -0.005607 0.008006 0.018350 -0.005890 -0.004179 0.001811 0.019777
0.000673 -0.005753 -0.045365 -0.001488 0.016821 0.000359 -0.005611 -0.013906 -0.000032 0.027898
-0.006095 -0.003364 -0.043093 -0.007743 0.022372 0.007518 -0.005686 -0.004445 -0.004046 0.024409
-0.001820 0.015352 -0.037703 0.004821 0.020568 -0.028915 0.006992 -0.009169 -0.020281 0.016134
0.003075 -0.002990 -0.048372 0.012588 0.003329 0.007372 -0.015720 -0.007468 0.001225 0.016118
0.008469 0.001528 -0.051274 0.008134 0.033441 0.006119 -0.000766 -0.009467 0.003871 0.014437
0.005616 -0.000346 -0.047836 -0.002901 0.021321 -0.002379 -0.000779 -0.022400 -0.007