Skip to content

Instantly share code, notes, and snippets.

View prerakmody's full-sized avatar
🏠
Working from home

pmod prerakmody

🏠
Working from home
View GitHub Profile
@prerakmody
prerakmody / camelyon16.py
Last active November 29, 2022 16:26
Using the timeit command
"""
Data: https://drive.google.com/drive/folders/1zPK--rbdnqK2T0NnTrfvujeSg4PkN_bH?usp=sharing (contains normal_001.tif)
Alternatively: https://aws.amazon.com/marketplace/pp/prodview-exkvqrznup6vc?sr=0-1&ref_=beagle&applicationId=AWSMPContessa#resources
"""
import os
import sys
import timeit
import numpy as np
sys.path.append('C:\\Program Files\\ASAP 2.1\\bin') # https://github.com/computationalpathologygroup/ASAP/releases/tag/ASAP-2.1
@prerakmody
prerakmody / ASAP-CentOS.md
Last active July 16, 2023 21:27
ASAP Installation (Whole Slide Images in Digital Pathology)

Install ASAP on CentOS Stream (within a conda environment as a non-root user)

Preliminary points

  1. The approach here is to first build/install dependencies of ASAP and then define their paths in the cmake command for ASAP. The order in which I build the dependencies is in the same order as defined using the find_package() function in ASAP/CMakeLists.txt.
  2. Assumptions
    • Note 1: I assume you have your conda environment installed and activated
    • Note 2: These instruction assume you have cmake installed. Find a basic tutorial here and a quick intuition here.
  • Note 3: These instruction also assume that you gcc --version is >=9 since otherwise it leads to issues with compiling #include in some .cpp files like [core/filetools.cpp](https://github.com/computationalpatholo
@prerakmody
prerakmody / camelyon16.py
Created November 24, 2022 13:08
Histopathology Image Reading
"""
CAMELYON 16 DATASET
- Whole Slide Images (WSI) containing histopathological information on breast cancer
1. Download
- To view the list of AWS
- Link: https://aws.amazon.com/marketplace/pp/prodview-exkvqrznup6vc?sr=0-1&ref_=beagle&applicationId=AWSMPContessa#resources
- Click on Resources on AWS --> View Resources
- Single Sample
- aws s3 cp --no-sign-request s3://camelyon-dataset/CAMELYON16/images/tumor_032.tif ./raw/tumor_032.tif
@prerakmody
prerakmody / nbia.md
Last active July 1, 2024 12:27
TCIA scripts

Datasets present in OHIF dicom server

Samples are writen down with their StudyInstanceUID as the header.

Other Referrences

  1. To get all collections in TCIA: link

Samples

  1. [StageII-Colorectal-CT --> CT-005] 1.3.6.1.4.1.14519.5.2.1.256467663913010332776401703474716742458
@prerakmody
prerakmody / hdc.py
Last active August 15, 2022 09:11
Receptive Field for dilated convolutions
"""
Motivation: Understanding Convolution for Semantic Segmentation (https://arxiv.org/pdf/1702.08502.pdf)
: https://stats.stackexchange.com/questions/265462/whats-the-receptive-field-of-a-stack-of-dilated-convolutions
"""
import pdb
import traceback
import numpy as np
import matplotlib.pyplot as plt
@prerakmody
prerakmody / actualsize.py
Created July 3, 2022 08:32
Object Size in python
import gc
import sys
import humanize # pip install humanize
def actualsize(input_obj):
# https://towardsdatascience.com/the-strange-size-of-python-objects-in-memory-ce87bdfbb97f
memory_size = 0
ids = set()
objects = [input_obj]
while objects:
@prerakmody
prerakmody / slurm-script.slurm
Last active July 30, 2025 15:15
SLURM Commands
#!/bin/bash
#SBATCH --job-name=<script-name>
#SBATCH --partition=<partition-name> # see qq command above
#SBATCH --gres=gpu:1
#SBATCH --nodelist=<node-name> # see qq command above
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=6
#SBATCH --mem-per-cpu=8G
#SBATCH --time=14-20:00:00
#SBATCH --mail-type=end
@prerakmody
prerakmody / contours_with_gt_pred.py
Last active September 6, 2022 12:04
Organ Contours (using matplotlib, opencv, scipy)
"""
This script shall plot contours using cv2 on an image
- Useful for plotting organ contours on a medical image
-- Note: Organ Mask should contain labels values in the [0,255] range
"""
# Standard Libraries
import pdb
import cv2
import numpy as np
@prerakmody
prerakmody / auc.py
Created January 13, 2022 11:17
Area Under the Curve (AUC) calculation
"""
References
1. Calculating area under the curve (AUC) using Riemann Sum - https://en.wikipedia.org/wiki/Riemann_sum
2. https://scikit-learn.org/stable/modules/generated/sklearn.metrics.auc.html#sklearn.metrics.auc
- it uses np.trapz()
- Code: https://github.com/numpy/numpy/blob/v1.22.0/numpy/lib/function_base.py#L4686-L4797
3. Other methods implemented in TFlow
- https://wikidocs.net/24605
- Note: This method only works right when we provide a list x that has evenly spaced values
@prerakmody
prerakmody / flipout_noneager_functionalapi.py
Last active September 30, 2021 13:27
Bayesian Models (Tensorflow 2.4.0 + Tensorflow Prob 0.12.1)
"""
OG Ref: https://github.com/tensorflow/probability/issues/620
Goals
- To experiment with DNNs built using Flipout layers in both eager and non-eager mode
- Eager mode allows for debugging using tf.print()
- Non-eager mode is supposed to be faster and less memory consuming since its pre-computes functions in a graph
- Models will be made using functional API and the dataset will not use tf.data.Dataset
Notes