Skip to content

Instantly share code, notes, and snippets.

View tashrifbillah's full-sized avatar

Tashrif Billah tashrifbillah

  • Harvard Medical School
  • Boston, MA
View GitHub Profile
@tashrifbillah
tashrifbillah / approxSignal.py
Last active February 18, 2020 23:47
Fit shm on reference data
from util import *
from rish import rish
N_shm=2
def approxSignal(imgPath, maskPath):
directory = os.path.dirname(imgPath)
inPrefix = imgPath.split('.nii')[0]
prefix = os.path.split(inPrefix)[-1]
outPrefix = os.path.join(directory, 'harm', prefix)
def single_pass(InputImage, scale):
temp_image= InputImage.copy()
for s in range(scale,0,-1):
temp_image= single_scale(temp_image, s)
temp_image= findLargestConnectMask(temp_image)
OutputImage= temp_image
antsApplyTransforms -d 3 -i /rds/general/user/fmoro/home/bioaxlive/Controls/DTI/London/COB_I078/harm_trial_4/COB_I078_mask.nii.gz \
-o /rds/general/user/fmoro/home/bioaxlive/Controls/DTI/London/COB_I078/harm_trial_4/COB_I078_mask_resampledWarped.nii.gz \
-r /rds/general/user/fmoro/home/template_lau4/template0.nii.gz \
-t /rds/general/user/fmoro/home/template_lau4/COB_I078_FA*[!Inverse]Warp.nii.gz \
-t /rds/general/user/fmoro/home/template_lau4/COB_I078_FA*GenericAffine.mat
# if the above does not work, do
ls /rds/general/user/fmoro/home/template_lau4/COB_I078_FA*[!Inverse]Warp.nii.gz
ls /rds/general/user/fmoro/home/template_lau4/COB_I078_FA*GenericAffine.mat
# and replace the last two lines in the former block with absolute paths obtained from the latter
#!/usr/bin/env python
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash_table import DataTable
from dash_table.Format import Format
import pandas as pd
app = dash.Dash(__name__)
@tashrifbillah
tashrifbillah / MAC-Windows-key-map.md
Last active March 20, 2023 17:28
MAC equivalent of widely used Windows keyboard keys

Windows and Linux users are accustomed to standard layout keyboard. When they have to work on a MacBook, the absence of some important keys may be felt. Here I put together the equivalent MacBook key sequences for the absent keys:

Key MS word Browser Terminal Vi / Vim
Home fn + command + shift + fn + fn +
End fn + command + shift + fn + fn +
* Page
Up
fn +
* Page
Down
fn +
* Delete fn + delete
* Backspace delete
@tashrifbillah
tashrifbillah / shape_check.py
Last active May 15, 2020 15:44
imgShape -- maskShape discrepancy
# run as python shape_check.py
from conversion import read_cases
import numpy as np
from nibabel import load
from os.path import isfile
# copy this script to DIAGNOSE_CTE_U01/derivatives/pnlpipe and run from there
# adjust caselist if necessary
cases=read_cases('../../caselists/Caselist_ALL.txt')
@tashrifbillah
tashrifbillah / fix_bbox.sh
Last active May 15, 2020 16:31
Fix bounding box of labelmap after Slicer ruined it
# copy this script in the following directory and run from there
# cd DIAGNOSE_CTE_U01/derivatives/pnlpipe
# run as sh fix_bbox.sh
for c in $(cat incongruous_cases.txt)
do
mask_name=sub-${c}/ses-01/dwi/sub-${c}_ses-01_desc-dwiXcCNNQc_mask.nii.gz
bse_name=sub-${c}/ses-01/dwi/sub-${c}_ses-01_desc-dwiXc_bse.nii.gz
echo $c
@tashrifbillah
tashrifbillah / simple_luigi_task.py
Last active November 14, 2020 05:23
Simple Luigi task, useful for debugging server issue
#!/usr/bin/env python
from luigi import build, Task, LocalTarget, FloatParameter
from luigi.util import requires
import numpy as np
class TaskA(Task):
a= FloatParameter(default=round(np.random.rand(),3))
@tashrifbillah
tashrifbillah / visualize_bvecs.py
Last active January 18, 2023 14:39
Visualize bvecs on a sphere
#!/usr/bin/env python
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.ticker as ticker
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import rand
from itertools import product, combinations
from conversion import read_bvecs, read_bvals, write_bvals
from os.path import abspath, splitext, basename
@tashrifbillah
tashrifbillah / app2.py
Last active June 1, 2020 20:35
Using same port on dash
#!/usr/bin/env python
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)