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 / load_miccai2015.py
Last active January 11, 2023 18:59
RayStation 10B - Upload .dcm (from disk), auto-contour (in RS) and download .dcm (to disk and not in PACS)
"""
To
1) upload DICOM (.dcm) data of a patient and
2) perform auto-contouring on it and
3) download the contours
Tested with Raystation1-B and python3.6
Note: The MICCAI2015 dataset only has 1 planning scan/patient
"""
@prerakmody
prerakmody / monailabel-docker-windows.md
Last active January 5, 2023 16:48
Docker Container (for MONAILabel) on Windows 11

Steps

  1. The following steps show how to run the MONAILabel server on Windows via Docker. I have tested these steps on the following software versions:

    Name Version Terminal Command
    Windows Microsoft Windows 11 Pro for Workstations Win Command Prompt systeminfo | findstr /B /C:"OS Name" /B /C:"OS Version
    Nvidia Driver 527.56 Win Command Prompt nvidia-smi --query-gpu=driver_version --format=csv
    Nvidia CUDA Driver API 12.0 Win Command Prompt nvidia-smi
    Nvidia GPU NVIDIA GeForce RTX 2080 Ti Win Command Prompt nvidia-smi --query-gpu=driver_version --format=csv

| WSL | 1.0.3.0 | Win Command Prompt | wsl --version |

@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.md
Last active November 16, 2022 13:44
SLURM Commands

Useful aliases

Add these aliases in your ~/.bashrc file. To use them, save the updated file and type . ~/.bashrc to reload the bash file

  1. View all running jobs
    • alias qq="watch -n 0.1 'squeue -u ppmody -o \"%.10i %.9P %.24j %.8u %.2t %.10M %.5D %R\" ; echo -e \"\n\" ; squeue -p LKEBgpu,highmemgpu,gpu --sort=\"N,-i\" -o \"%.10i %.9P %.12j %.8u %.2t %.10M %.5D %.16R %.3C %.7m %b\"; echo -e \"\n\"; sinfo -a' "
      
  2. View resources within the cluster
    • alias qqq="scontrol -o show nodes |grep -e \"lkeb\" -e \"gpu.ai\" -e \"gpu\"| awk '{ print \$1, \$4, \$5, \$9, \$23, \$24, \$25}'"
      
@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