Skip to content

Instantly share code, notes, and snippets.

View dtxe's full-sized avatar

Simeon Wong dtxe

View GitHub Profile
@dtxe
dtxe / linkDs.sh
Created May 30, 2017 17:23
Symlink CTF *.ds, with renaming
#!/bin/bash
#
# Simeon Wong
if [ -d $1 ]
then
# make destination directory
mkdir $2
SRCBASE=$(basename $1 .ds)
#!/bin/bash
# Usage dicom_to_nifti_anonymize [source dir] [dest dir] [participant ID]
if [[ $# -lt 2 ]]; then
DEST=$1
else
# make the directory if it doesn't exist
if [ ! -d $2 ]; then
mkdir $2
fi
%% transforms
% transform into fsl coordinates (CT)
fslpos = elec.elecpos;
fslpos(:,4) = 1;
fslpos = (img_ct.transform \ fslpos')';
if img_ct.hdr.x_r == 1
fslpos(:,1) = img_ct.dim(1) - fslpos(:,1);
end
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 5 11:40:07 2019
@author: simeonwong
"""
import pyedflib
import os.path
@dtxe
dtxe / scrape_bible_plan.sh
Last active December 11, 2023 17:32
Scrape BibleProject discussion posts from YouVersion bible plans
#!/bin/bash
PLANID=12345678
JWTTOKEN={{TOKEN}}
for DAY in {1..365}
do
curl 'https://plans.youversionapi.com/4.0/together/$PLANID/activities?day=$DAY&page=1&order=desc&talk_it_over=0' \
-H 'authority: plans.youversionapi.com' \
-H 'x-youversion-app-version: 4' \
@dtxe
dtxe / circ_buffer_speedtest.py
Created March 9, 2021 01:11
Test which implementation of circular buffers is fastest for receiving chunks of streaming data
import numpy as np
from collections import deque
import datetime
iters = 2000
values = np.random.rand(10000)
def nproll():
@dtxe
dtxe / fixQpdf.sh
Created October 20, 2021 19:42
Use ghostscript to repair all PDFs within a ZIP file (of student submissions from UofT Quercus)
#!/bin/bash -x
# fixQpdf.sh [zip file] [output folder]
BASEDIR=$HOME
TEMPDIR=$(uuidgen)
mkdir $BASEDIR/$TEMPDIR
mkdir $BASEDIR/$2
def list_mutator(inner_list):
inner_list.append(4)
def list_setter(inner_list):
inner_list = inner_list + [4]
def list_returner(inner_list):
inner_list = inner_list + [4]
return inner_list
@dtxe
dtxe / installgfortran.sh
Last active November 9, 2022 17:43
backport install libgfortran3 and g++-6 on ubuntu 20.04 focal for simbio and fieldtrip
#!/bin/bash
cat - << EOF > /etc/apt/sources.d/bionic.list
deb http://ca.archive.ubuntu.com/ubuntu/ bionic main
deb http://ca.archive.ubuntu.com/ubuntu/ bionic universe
EOF
apt update
apt install -y g++-6
apt install -y libgfortran3
@dtxe
dtxe / dump_dicom_headers.py
Last active March 3, 2023 20:10
quick and dirty script to glob a directory of dicom files and extract the header information into a csv file
''' quick and dirty script to glob a directory of dicom files and extract the header information into a csv file '''
import pydicom
import glob
import pandas as pd
from tqdm import tqdm
import numpy as np
###########################
# Parameters