Skip to content

Instantly share code, notes, and snippets.

View ilkayisik's full-sized avatar

Ilkay Isik ilkayisik

View GitHub Profile
@ilkayisik
ilkayisik / exclude_sub.py
Created January 15, 2020 12:59
create list of subjects by excluding some subjects
nr_sub = 26
subj_list = []
[subj_list.append('sub-{:02d}'.format(s+1)) for s in range(nr_sub)]
ex_subj = [0, 1, 2, 15, 18]
ex_subj_list = ['sub-{:02d}'.format(i+1) for i in ex_subj]
subj_list2 = [i for i in subj_list if i not in ex_subj_list]
tksurferfv fsaverage lh inflated -aparc -overlay sig.mgh -fminmax 2 3
@ilkayisik
ilkayisik / remove_file_names_ifcontains.py
Last active January 9, 2020 09:53
remove files based on expression in the file name and create text files with those files
from glob import glob
sub_exc = [0, 1, 2, 15, 18]
sub_list = ['sub-{:02d}'.format(s+1) for s in sub_exc]
files1 = [i for i in files1 if i.rsplit('analysis/',1 )[1].split('/')[0] not in sub_list]
files2 = [i for i in files2 if i.rsplit('analysis/',1 )[1].split('/')[0] not in sub_list]
files3 = [i for i in files3 if i.rsplit('analysis/',1 )[1].split('/')[0] not in sub_list]
files = [files1, files2, files3]
for fname_full in $(ls $sub_ses/prepro/source_files/*.nii); do
@ilkayisik
ilkayisik / reslice_with_c3d.sh
Created October 11, 2019 10:36
use convert 3D to reslice a 2mm input to be 1mm
root='/Users/ilkay.isik/project_folder_temp/fc_content/MRI_data/lscp_data/derivatives'
input=path/to/2mm_input.nii
output=path_to_1mm_output.nii
ref=path_to_1mm_ref.nii
c3d ${ref} ${input} -int 0 -reslice-identity -o ${output}
# to be used to save jupyter notebooks as html files
import os
from ilkay_tools.jupyter_save import save_nb, output_html
import time
%%javascript
IPython.notebook.kernel.execute(`notebookName = '${IPython.notebook.notebook_name}'`);
nb_fdir = os.getcwd()
nb_name = notebookName.split('.', 1)[0] # discard the extension
var="hello/my/name/is"
# everything after the first slash:
echo "${var#*/}"
# everything after the last slash:
echo "${var##*/}"
# everything before the first slash:
echo "${var%%/*}"
@ilkayisik
ilkayisik / matplotlib_subplots.py
Last active July 3, 2019 14:33
Use matplotlib to create subplots with time series plots using 2 for loops [here for subjects and movies]
import matplotlib.pyplot as plt
import seaborn as sns
for s in range(nr_subjects):
fig, ax = plt.subplots(5, 6, sharex=True, sharey=True, figsize=(15, 20))
sns.despine()
ax = ax.flatten()
for m in range(nr_movies):
ax[m].plot(cdt[s, m, :])
ax[m].plot(cdrt[s, m, :])
@ilkayisik
ilkayisik / copy_folders.sh
Created June 3, 2019 17:05
copy certain folders to another place with a subject loop
for sub in {01..26}; do
echo sub-${sub}
mkdir /Users/ilkay.isik/MPI-Documents/hack_19/data/analysis/sub-${sub}
mkdir /Users/ilkay.isik/MPI-Documents/hack_19/data/analysis/sub-${sub}/pfobloc
src=/Users/ilkay.isik/project_folder_temp/fc_content/MRI_data/lscp_data/derivatives/analysis/sub-${sub}/pfobloc/pfobloc.feat
dest=/Users/ilkay.isik/MPI-Documents/hack_19/data/analysis/sub-${sub}/pfobloc/pfobloc.feat
echo ${src} '****' ${dest}
cp -r ${src} ${dest}
done
@ilkayisik
ilkayisik / change_bg_color_imagemagick.sh
Last active May 2, 2019 19:57
various bash operations in one file including forloop, listing all files in a directory, manipulate names to create output name, change backgeound color with image magick
root=pat/to/root
cd ${root}
for tiffile in *.tif; do
echo $tiffile
in_file=${tiffile}
out_file=${in_file%.*}_whitebg.tif
convert -fill white -opaque black ${in_file} ${out_file}
done