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 / jupyter-nginx.md
Created October 2, 2024 15:04
Connect to Jupyter kernel remotely through Nginx proxy

In addition to the proxy_set_header stuff, I had to adjust my SELinux config:

setsebool -P httpd_read_user_content=on

systemctl restart nginx

I also needed the --ServerApp.allow_remote_access=True flag:

@tashrifbillah
tashrifbillah / explore_figs.py
Last active September 2, 2024 18:19
Explore values in FIGS form
#!/usr/bin/env python
import pandas as pd
from glob import glob
new_vars="chrfigs_mother_ddx,chrfigs_mother_ddx_agree,chrfigs_mother_ddx_why,chrfigs_mother_mdx,chrfigs_mother_mdx_agree,\
chrfigs_mother_mdx_why,chrfigs_mother_pdx,chrfigs_mother_pdx_agree,chrfigs_mother_pdx_why,chrfigs_mother_napdx,\
chrfigs_mother_napdx_agree,chrfigs_mother_napdx_why,chrfigs_mother_apdx,chrfigs_mother_apdx_agree,chrfigs_mother_apdx_why,\
chrfigs_father_ddx,chrfigs_father_ddx_agree,chrfigs_father_ddx_why,chrfigs_father_mdx,chrfigs_father_mdx_agree,\
chrfigs_father_mdx_why,chrfigs_father_pdx,chrfigs_father_pdx_agree,chrfigs_father_pdx_why,chrfigs_father_napdx,\
@tashrifbillah
tashrifbillah / NDA-DATA-DICT.md
Last active August 28, 2024 15:58
Method for creating an NDA format data dictionary

This documentation is created by Tashrif Billah for referring AMP-SCZ collaborators about how to make an NDA-format dictionary definition. The latter has to be sent to ndahelp@mail.nih.gov to create the actual data dictionary. Copy the and start editing it according to the following instructions:

ElementName:

      Must be less than 30 characters. It could be identical to REDCap variable name. If a REDCap variable does not exist, make up a proper name.

DataType:

  • String
  • Date
@tashrifbillah
tashrifbillah / debug_psychs01.py
Last active August 13, 2024 22:28
Troubleshoot omission of all PRESCIENT cases from ampscz_psychs01_{baseline,month_1,month_2}
#!/usr/bin/env python
# cd /data/predict1/to_nda/nda-submissions/network_combined
df=pd.read_csv('/data/predict1/home/dm1447/data/ampscz_all_subjects.csv')
df.set_index('subject_id',inplace=True)
dfpre=pd.read_excel('form_status_tracker_PRESCIENT.xlsx')
dfpre.set_index('subject',inplace=True)
@tashrifbillah
tashrifbillah / explore_new_cnb.py
Created July 30, 2024 16:05
Explore new Penn CNB data structure to identify problems
from glob import glob
import json
dict1={'1':'SPLLT-A','2':'SPLLT-B','3':'SPLLT-C','4':'SPLLT-D','5':'PLLT-A','6':'PLLT-B','':'_______'}
files=glob('Pr*/PHOENIX/PROTECTED/Pr*/raw/???????/surveys/*.UPENN_nda.json')
# odd number of sessions and not provided cnb_pllt_test
for file in files:
with open(file) as f:
@tashrifbillah
tashrifbillah / reorder_charts.py
Last active June 26, 2024 21:00
Reorder charts on DPdash
#!/usr/bin/env python
import json
reordered='/data/predict1/charts1.json'
raw='/data/predict1/predict-mongodb-backup/charts_20240612.json'
# find out the private charts in raw
# print 0-indexed indices of private charts from raw file
import pandas as pd
df=pd.read_csv('pennebakerctq01_definitions.csv')
dfgiven=pd.read_excel('cnb_ndar_codebook_v5.xlsx')
_aliases=df['Aliases'].unique()
__aliases=[]
for e in _aliases:
if pd.isna(e):
@tashrifbillah
tashrifbillah / encrypt_decrypt.sh
Created December 8, 2023 04:37
Commands for encrypting and decrypting a message using SSH's public/private key pair
#!/bin/bash
# convert SSH public key to pem format
ssh-keygen -e -m PKCS8 -f git_rsa.pub > git_rsa.pem
# encrypt
openssl rsautl -encrypt -pubin -inkey git_rsa.pem -in message.txt -out message.enc
# decrypt
openssl rsautl -decrypt -inkey git_rsa -in message.enc
@tashrifbillah
tashrifbillah / fluid_shipment_anomalies.py
Last active July 2, 2024 19:15
Detect fluid_shipment_anomalies
import pandas as pd
# cd /data/predict1/to_nda/nda-submissions
df=pd.read_csv('blood_saliva_rack_Pronet.csv')
index=[]
for i,row in df.iterrows():
rc=row['Rack Code']