Skip to content

Instantly share code, notes, and snippets.

View stowler's full-sized avatar

Stephen Towler stowler

View GitHub Profile
@stowler
stowler / gist:5397713
Created April 16, 2013 17:16
mm->vox integers per AFNI 3dmaskdump INPUT
AFNI 3dmaskdump INPUT
------------------------------------------------
Appears to use system rounding rint() to convert coordinate floats to integers:
If user inputs mm coordinates as 3dmaskdump argument, 3dmaskdump converts them to
integer "index coordinates" using serial calls to three functions:
1) THD_dicomm_to_3dmm() (from thd_coords.c)
2) THD_3dmm_to_3dfind() (from thd_coords.c)
3) rint() (from system's buit-in c math, or from faked version in mri_free.c)
@stowler
stowler / gist:5397749
Created April 16, 2013 17:20
mm->vox integers per AFNI 3dmaskdump OUTPUT
AFNI 3dmaskdump OUTPUT:
------------------------------------------------
Appears to use implicit casting and a custom log-based algorithm to convert
coordinate floats to integers:
If user requests integer voxel coordinates (not mm), 3dmaskdump creates them
from internal float voxel coordinates (not mm) using functions in multivector.c:
MV_format_fval(), which calls MV_fval_to_char()
e.g., here 3dmaskdump calls for outputting integer voxel coordinate ijk:
@stowler
stowler / gist:5397788
Last active December 16, 2015 07:19
mm->vox integers per AFNI controller window user INPUT
AFNI controller window user INPUT
------------------------------------------------
Appears to use implicit casting + boundary handling to create integer voxel
coordinates from the user-specified mm coordinates in the "Jump to (xyz)" box:
In afni.c , typical use of AFNI_jumpto_dicom() calls AFNI_jumpto_dicom_OLD(),
which converts user-provided mm coordinates to integer voxel coordinates in
three steps:
@stowler
stowler / gist:5397958
Created April 16, 2013 17:45
mm->vox integers per AFNI controller window OUTPUT
AFNI controller window OUTPUT
------------------------------------------------
Appears to pull existing integer voxel coordinates from internal integer-based
data structures. Doesn't need conversion from float to integer.
When the AFNI controller window is set to display voxel coordinates for the
current crosshair location (GUI "Set Coord Order"->"Voxel Indexes"), it displays
integer coordinates pulled from internal integer data structures.
from afni.c :
@stowler
stowler / gist:5398170
Last active December 16, 2015 07:19
mm->vox integers per FSL fslview cursor widget
FSL fslview cursor widget
------------------------------------------------
Appears to use explicit casting to convert float mmm coordinates to integer
voxel coordinates, truncating in the process:
line 266 from fslview's cursorwidget.cpp:
232 void CursorWidget::mmBoxChanged()
233 {
...
@stowler
stowler / gist:5399213
Created April 16, 2013 20:13
mm->vox integers per FSL fslmeants INPUT
FSL fslmeants INPUT
------------------------------------------------
Appears to round coordinate floats to integers via MISCMATHS::round
(adding or subtracting .5 then truncating decimal via cast):
If user inputs mm coordinates as fslmeants argument (-c --usemm), fslmeants
rounds to integer voxel coordinates using call to MISCMATHS::round().
From fslmeants.cc:
@stowler
stowler / gist:5399226
Created April 16, 2013 20:14
mm->vox integers per FSL fslmeants OUTPUT
FSL fslmeants OUTPUT
------------------------------------------------
If user requests voxel coordinate output (not mm) via fslmeants --showall,
fslmeants doesn't appear to convert floats to integers. It just matrix
transforms internal voxel coordinates (which already lack decimal values due to
their row/slice/column nature) to nifti voxel coordinates.
From fslmeants.cc:
311 if (showall.value()) {
@stowler
stowler / gist:5445189
Created April 23, 2013 16:32
PiB voxel size conflict: FSL and AFNI read as 2x2x2 mm voxels due to header's s-form (despite header's pixdim values of 1.2x1.2x1.2 mm)
$ 3dinfo ~/Downloads/ftp.medimg.emory.edu/NMCardiac/JonNye/PiB_binding_maps/NIFTI/VN040_20110412_LI_rsl.nii
++ 3dinfo: AFNI version=AFNI_2011_12_21_1014 (Dec 1 2012) [64-bit]
Dataset File: /home/stowler-local/Downloads/ftp.medimg.emory.edu/NMCardiac/JonNye/PiB_binding_maps/NIFTI/VN040_20110412_LI_rsl.nii
Identifier Code: NII_MVGvk3_9itSHbYxclrBKWw Creation Date: Tue Apr 23 12:23:56 2013
Template Space: ORIG
Dataset Type: Anat Bucket (-abuc)
Byte Order: LSB_FIRST {assumed} [this CPU native = LSB_FIRST]
Storage Mode: NIFTI
Storage Space: 25,090,560 (25 million) bytes
@stowler
stowler / lut_convertToFslview.sh
Last active June 20, 2017 19:00
lut_convertToFslview.sh : an unsafe proof-of-concept bash script for converting LUTs to fslview LUTs
#!/bin/bash
#
# CALL AS: lut_convertToFslview.sh
# (no arguments: input and output files defined below)
#
# CREATED: 20130430 by stowler@gmail.com
# LAST UPDATED: same
#
#
#
@stowler
stowler / test-epiPETandT1toMNI152.sh
Created May 1, 2013 21:51
for meeting with Pearce and Evan: proof-of-concept parent script for PET & T1 coregistration to MNI152
#!/bin/bash
# A short proof-of-concept script for meeting with Pearce and Evan (W, 20130501)
#
# Demonstrates adaptation of existing tools for automated PET->T1->MNI152
# registration.
#
# INPUT: dicoms for a deidentified participant's T1 and PET sequences.
#
# OUTPUT: PET and T1 nifti volumes nonlinearly registered to MNI152 template (RPI).