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 / 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']
@tashrifbillah
tashrifbillah / format_for_rcloud.py
Created August 16, 2023 14:42
Format REDCap data for REDCap cloud
#!/usr/bin/env python
import sys
import pandas as pd
df=pd.read_csv(sys.argv[1],dtype=str)
df1=df.copy()
df1.rename(columns={'chric_record_id':'participant_id'},inplace=True)
df1["redcap_system_data_format_version"]=1
@tashrifbillah
tashrifbillah / troubleshoot1.py
Created August 1, 2023 20:27
formqc troubleshooting
#!/usr/bin/env python
from glob import glob
from os.path import isfile, basename
import pandas as pd
subjects=glob('/data/predict1/data_from_nda/Pronet/PHOENIX/PROTECTED/*/raw/*')
subjects=[basename(s) for s in subjects]
print('for how many subjects inclusionexclusion_criteria_review does not exist?')
@tashrifbillah
tashrifbillah / avl_qc_transcript_status.py
Created June 20, 2023 22:14
Check status of AVL combined QC records and transcripts' existence
# execute it from within /data/predict1/data_from_nda/Prescient/PHOENIX/GENERAL
from os.path import dirname, join as pjoin
import pandas as pd
from glob import glob
files=glob('*/processed/*/interviews/open/*_combinedQCRecords.csv')
j=0
for file in files:
@tashrifbillah
tashrifbillah / erase_calc_logic.py
Last active September 7, 2023 18:40
Erase calcs, logics from REDCap dict to upload to a REDCap project
import pandas as pd
# this is API pulled from Yale REDCap
filename='pronet_dict_20230321.csv'
df=pd.read_csv(filename, dtype=str)
df1=df.copy()
# erase calcs, logics
# replace calc by text
@tashrifbillah
tashrifbillah / get_formqc_count.py
Created May 12, 2023 15:39
Count important variables for DPdash charts
#!/usr/bin/env python
import pandas as pd
from glob import glob
def get_count():
for file in files:
df=pd.read_csv(file)