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 / dicomweb.json
Created October 28, 2024 09:32
Orthanc config JSONs
{
"DicomWeb" :
{
"Enable" : true, // Whether DICOMweb support is enabled
"Root" : "/dicom-web/", // Root URI of the DICOMweb API (for QIDO-RS, STOW-RS and WADO-RS)
"EnableWado" : true, // Whether WADO-URI (aka. WADO) support is enabled
"WadoRoot" : "/wado", // Root URI of the WADO-URI (aka. WADO) API
"Host" : "localhost:8042", // Hard-codes the name of the host for subsequent WADO-RS requests
"Ssl" : false, // Whether HTTPS should be used for subsequent WADO-RS requests
"Servers" : {
@prerakmody
prerakmody / getContourScribbleForBinarySlice.py
Last active October 27, 2024 16:33
Scribble Generation (in an auto segmentation editing scenario)
import skimage
import skimage.morphology
import voxynth as voxynth # https://github.com/dalcalab/voxynth
import numpy as np
import matplotlib.pyplot as plt
def getContourScribbleForBinarySlice(mask, show=False):
"""
Params
------
@prerakmody
prerakmody / dataloaderCompare.py
Last active June 1, 2024 14:12
TORCH MULTIPROCESSING
import torchDataloader
import myDataloader
import pdb
import copy
import time
import tqdm
import pprint
import traceback
import numpy as np
@prerakmody
prerakmody / svlsTensorflow.py
Created April 19, 2024 09:42
Stochasticaly Varying Spatial Smoothing (SVLS)
def get_svls_filter_3d(kernel_size=3, sigma=1, verbose=False):
"""
Ref: https://github.com/mobarakol/SVLS/blob/main/svls.py (pytorch)
- Alternative (for gauss kernel): https://gist.github.com/blzq/c87d42f45a8c5a53f5b393e27b1f5319
Note: group parameter in Conv3D is giving an issue in tf==2.10.0 on Unix
- "tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc:453] ptxas returned an error during compilation of ptx to sass: 'INTERNAL: Failed to launch ptxas'"
"""
try:
@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 August 10, 2024 17:10
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