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 / 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 / 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)
@tashrifbillah
tashrifbillah / app1.py
Created June 1, 2020 20:35
Dash using same port
#!/usr/bin/env python
import dash
import dash_html_components as html
import dash_core_components as dcc
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
@tashrifbillah
tashrifbillah / share_data_callbacks.py
Created June 17, 2020 15:08
Sharing data between callbacks in Dash
# See my issue at https://community.plotly.com/t/using-dcc-interval-for-continuous-update/41071/12
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import logging
# from time import sleep
from tempfile import gettempdir
from os import getpid, remove
from os.path import join as pjoin, isfile
@tashrifbillah
tashrifbillah / df_line_wrap.py
Last active June 18, 2020 17:01
OHBM Hackathon project of Dave and Nazek
import pandas as pd
import pdfkit
df=pd.DataFrame(columns= ['col 1', 'col 2'])
df.loc[0]=[1,2]
df.loc[1]=[3,4]
df.loc[3]=["2020-06-05 00:50:22.953896: E tensorflow/stream_executor/cuda/cuda_driver.cc:806] failed to allocate 225.53M (236486144 bytes) from device: CUDA_