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 / loadCTInCornerstone.html
Created January 24, 2024 10:51
Cornerstone.js for loading a folder of .dcm files
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
<script src="https://unpkg.com/cornerstone-core/dist/cornerstone.js"></script> <!-- cornerstone-core - 2.6.1 - 2021-11-19 -->
<script src="https://unpkg.com/cornerstone-tools/dist/cornerstoneTools.js"></script> <!-- cornerstone-tools - 6.0.10 - 2023-07-21 -->
<script src="https://unpkg.com/cornerstone-math/dist/cornerstoneMath.js"></script> <!-- cornerstone-math - 0.1.10 - 2022-06-09 -->
@prerakmody
prerakmody / ct-rtdose-plot.py
Last active October 8, 2023 01:53
DICOM (CT and RTDOSE) mapping in matplotlib
"""
Step 1 - Read Dose and CT .dcm files
Step 2 - Resample dose to CT
Step 3 - Plot
"""
import pdb
import pydicom
import traceback
import numpy as np
import SimpleITK as sitk
@prerakmody
prerakmody / copyPlan.py
Last active July 13, 2023 09:12
Raystation - Dual Arc Beam
import connect
RS_CHECK_PREFIX = '_'
RS_STR_TRANSLATE_OBJ = { ord(' ') : ord('_') , ord('(') : ord('_') , ord(')') : ord('_') , ord('-') : ord('_') , ord('+') : ord('_') , ord('<') : ord('_') , ord('>') : ord('_') }
KEYNAME_PATIENT = 'Patient'
def checkForRTPlan(case, planName):
exists = False
if RS_CHECK_PREFIX + str(planName).translate(RS_STR_TRANSLATE_OBJ) in dir(case.TreatmentPlans):
exists = True
@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 &gt;=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
# Inspired by https://github.com/jzagoli/ProstateX2nii. Modified by Prerak Mody
# This processes this dataset --> https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=61080779#61080779ccf02ddde6884e4ba1ec73d08be362c6
# Alternatively, one could also look here --> https://github.com/rcuocolo/PROSTATEx_masks/tree/master/Files/prostate for this dataset (https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=23691656)
import pdb
import tqdm # pip install tqdm
import urllib
import zipfile
import nibabel # pip install nibabel
import pydicom # pip install pydicom
@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