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 / 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_
@tashrifbillah
tashrifbillah / sqlite_db_browser.py
Last active November 18, 2020 18:56
db file browser
#!/usr/bin/env python
import sqlite3
from os.path import abspath
import sys
conn= sqlite3.connect(abspath(sys.argv[1]))
cur = conn.cursor()
cur.execute("SELECT * FROM tasks")
@tashrifbillah
tashrifbillah / dash_pid.py
Created July 1, 2020 21:28
Minimal dash app for testing PID
#!/usr/bin/env python
import base64, io
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from dash_table import DataTable
from dash.exceptions import PreventUpdate
import plotly.graph_objects as go
@tashrifbillah
tashrifbillah / dash_png.py
Created July 1, 2020 23:32
Displaying *png, *jpg image on a dash app
import dash
import base64
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_core_components as dcc
app = dash.Dash(__name__)
test_png = r'C:\Users\tashr\Downloads\20190318_114007.jpg'
@tashrifbillah
tashrifbillah / tensor_nan_check.py
Last active July 22, 2020 13:31
Check existence of np.nan and np.inf in a vtk file
#!/usr/bin/env python
import vtk
import sys
import numpy as np
from vtk.util.numpy_support import vtk_to_numpy, numpy_to_vtk
infile=sys.argv[1]
print(infile)
@tashrifbillah
tashrifbillah / script1.py
Last active August 31, 2020 14:02
Luigi support 1
#!/usr/bin/env python
import logging
import time
import luigi
logger = logging.getLogger(__name__)
@tashrifbillah
tashrifbillah / bias_hist.py
Created August 19, 2020 19:10
Histogram of bias fields for a DWI
#!/usr/bin/env python
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib import pyplot as plt
from conversion import read_bvals
import nibabel as nib
import sys
import numpy as np
from os.path import join as pjoin
@tashrifbillah
tashrifbillah / tornado_app.py
Last active August 31, 2020 14:38
Basic tornado application
#!/usr/bin/env python
import tornado.ioloop
import tornado.web
import tornado.httpserver
# access as http://localhost:8888/tornado/
def make_app():
settings = {}