Skip to content

Instantly share code, notes, and snippets.

View fk128's full-sized avatar

Fahdi Kanavati fk128

View GitHub Profile
@fk128
fk128 / generate_mip.py
Created May 1, 2024 13:22
Generate resampled MIP image from dicom
import SimpleITK as sitk
import numpy as np
from imageio import imwrite
from argparse import ArgumentParser
"""
requirements.txt
SimpleITK
numpy
@fk128
fk128 / pgadmin.yaml
Last active May 19, 2023 12:46
k8s deployment of pgadmin with server setup from env variable
---
apiVersion: v1
kind: Service
metadata:
labels:
app: pgadmin
name: pgadmin
spec:
ports:
- name: pgadmin
@fk128
fk128 / bn_variant.py
Created May 21, 2021 07:44
mean only and STD only batch normalization - Tensorflow 2
from tensorflow.keras import layers
import tensorflow as tf
class MeanOnlyBN(layers.BatchNormalization):
def __init__(self, **kwargs):
kwargs['scale'] = False
kwargs['center'] = False
kwargs['fused'] = False
super().__init__(**kwargs)
import os
import argparse
import glob
import re
import time
MIN = -1024
MAX = 3072
@fk128
fk128 / insert_text_overlay_at_timestamps.jsx
Created April 28, 2018 14:13
insert text overlays at timestamps in after effects from text file input
/**
* Modified from:
SRT subtitle import for AE CS5
By August Bering
*/
/*
example text file input containing:
0:15
@fk128
fk128 / respliceVideoAE.jsx
Created April 28, 2018 14:06
re-splice video file in after effects given time stamps
{
// create an undo group
app.beginUndoGroup("respliceScript");
var curItem = app.project.activeItem;
var selectedLayers = curItem.selectedLayers;
var times = ["00.10-00.24", "00.34-01.03", "01.25-01.37"];
@fk128
fk128 / generate_random_colormap_itksnap.py
Created April 6, 2018 16:58
generate a random colormap for itk-snap. Useful for supervoxels.
import random
import sys
def print_xml_format(color, index, value):
if value == 0 or value == 1:
ctype = 'Discontinuous'
else:
ctype = 'Continuous'
print('''<folder key="ControlPoint[{}]" >
#!/bin/bash
# add border to image for 4x5 aspect ratio using imagemagick
# add_border.sh image.jpg
infile=$1
outfile=${1%.jpg}_border.jpg
bgcolor="white"
hh=`convert $infile -ping -format "%h" info:`
ww=`convert $infile -ping -format "%[fx:0.8*h]" info:`
@fk128
fk128 / InputParser.py
Last active August 19, 2019 10:02
Combined use of argparser and configparser.
import configparser
import os
from argparse import ArgumentParser
"""Example
# Reads configs from a config file using configparser. Use -c or --config to specify path to file.
# Arguments are overridden based on order of priority:
# defaults < config file < command line arguments
@fk128
fk128 / jrnl
Created December 1, 2017 13:59
jrnl bash completion for listing journals
# place file in /etc/bash_completion.d/
_jrnl()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="`jrnl -ls`"
if [ "$COMP_CWORD" -eq 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )