Skip to content

Instantly share code, notes, and snippets.

View kaczmarj's full-sized avatar

Jakub Kaczmarzyk kaczmarj

View GitHub Profile
#!/usr/bin/env bash
source ${FSLDIR}/etc/fslconf/fsl.sh
jupyter-lab --ip=*
#!/usr/bin/env bash
set -e
set +x
# This bash script:
# 1. adds the CRAN repository
# 2. installs R
# 3. installs R packages for AFNI
#
@kaczmarj
kaczmarj / merge_packfiles.sh
Last active August 9, 2017 19:46
Merge [ReproZip](https://www.reprozip.org/) pack files
#!/usr/bin/env bash
# This script merges multiple ReproZip version 2 pack files.
#
# Example:
#
# bash merge_packfiles.sh -o merged.rpz packA.rpz packB.rpz packC.rpz
#
#
# Requires reprozip and rsync.
"""Example of how to get volume of tumor from mask NIfTI."""
import nibabel as nb
# The mask nifti image has contains a 1 in voxels that contain
# tumor and a 0 in voxels that do not contain tumor.
mask_filepath = "/path/to/tumor_mask.nii.gz"
img = nb.load(mask_filepath)
data = img.get_fdata()
@kaczmarj
kaczmarj / neurodocker_script.py
Created January 11, 2019 16:28
scripted neurodocker
import neurodocker
specs = {'pkg_manager': 'apt', 'instructions': [['base', 'debian'], ['install', ['git', 'vim']]]}
dockerfile_string = neurodocker.Dockerfile(specs).render()
print(dockerfile_string)
FROM ubuntu:trusty
RUN apt-get -qq update \
&& apt-get install -yq --no-install-recommends \
curl \
git \
graphviz \
libgraphviz-dev \
pkg-config \
software-properties-common \
"""Filter slides with red titles from powerpoints, and save the filtered slides as one PDF file.
This script can only be run on Windows because it requires some Windows-specific libraries.
How to use
----------
- Install comtypes, pypdf2, and python-pptx using pip. Powerpoint must also be installed.
- Put all of the powerpoints to be filtered in one directory.
- Navigate to that directory in a terminal.
- Run this script. After some time, a file will be created named "output.pdf" with the filtered slides.
@kaczmarj
kaczmarj / tf_probability_mirroredstrategy.py
Created March 27, 2020 03:13
training a bayesian neural network with mirrored strategy
# Training a bayesian neural network with mirrored strategy.
# When using `model.fit`, the keras symbolic tensor error arises, and the common fix of
# experimental_run_tf_function=False does not fix it. Creating our own training loop seems to fix it.
# With lots of help from https://www.tensorflow.org/tutorials/distribute/custom_training#training_loop
from nobrainer.models import bayesian
import numpy as np
import tensorflow as tf
# Set up multi-gpu things.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kaczmarj
kaczmarj / sequential_filenames.go
Created June 22, 2020 02:52
Prepend filenames in a directory with an integer in ascending order of modified time. Integer prefixes are zero-padded based on the number of files in the directory.
package main
import (
"fmt"
"io/ioutil"
"log"
"math"
"os"
"path"
"sort"