This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for file in ./*.pdf; | |
do | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.6 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf "$file"; | |
mv -- output.pdf "$file"; | |
done; | |
rm output.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import matplotlib.pyplot as plt | |
from scipy.signal import resample | |
import numpy as np | |
from sklearn.metrics import roc_auc_score, roc_curve | |
def bootstrap_auc(y_true, y_pred, ax, nsamples=1000): | |
from scipy.interpolate import interp1d | |
auc_values = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig, ax = plt.subplots(1,1, figsize=(4, 3), dpi=80) | |
ims = list() | |
for index, image_slice in enumerate(tqdm(X)): | |
im = ax.imshow(image_slice[...,0], cmap=custom_colormap) | |
ims.append([im]) | |
im_ani = animation.ArtistAnimation(fig, ims, interval=200, repeat_delay=300, blit=True) | |
im_ani.save(os.path.join(selected_fold_folder, 'test.gif'), writer='imagemagick') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import SimpleITK as sitk | |
def bounding_box(arr, padding=0, square=False): | |
a = np.where(arr != 0) | |
if a[0].size and a[1].size: | |
min_ax0 = np.min(a[0]) | |
max_ax0 = np.max(a[0]) | |
min_ax1 = np.min(a[1]) | |
max_ax1 = np.max(a[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load a prostate image, change the name to 1 and create an empty label map for it in editor, then paste the following code | |
# in python interactor. | |
import DeepInfer | |
import os | |
from collections import OrderedDict | |
import json | |
logic = DeepInfer.DeepInferLogic() | |
parameters = DeepInfer.ModelParameters() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
MAINTAINER Alireza Mehrtash <mehrtash@bwh.harvard.edu> | |
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 | |
ENV CONDA_DIR /opt/conda | |
ENV PATH $CONDA_DIR/bin:$PATH | |
RUN apt-get update --fix-missing && apt-get install -y wget bzip2 ca-certificates \ | |
libhdf5-dev g++ graphviz libglib2.0-0 libxext6 libsm6 libxrender1 \ | |
git mercurial subversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#directory = 'G:/01-Work/QIICR/DCE BAT project/QIBA/QIBA_v9_Tofts/QIBA_v9_Tofts_Siemens_Orig' | |
#directory = 'G:/01-Work/QIICR/DCE BAT project/QIBA/QIBA_v8_Tofts/QIBA_v8_Tofts_GE/S0_5000' | |
directory = 'G:/01-Work/QIICR/DCE BAT project/QIN Prostate (From TCIA)/QIN PROSTATE' | |
studyFolders = os.listdir(directory) | |
fullPathStudyFolders = [] | |
for index,studyFolder in enumerate(studyFolders): | |
fullPathStudyFolders.append(os.path.join(directory, studyFolder,'DICOM')) | |
for i,folder in enumerate(fullPathStudyFolders): | |
print studyFolders[i] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lm = slicer.app.layoutManager() | |
rw = lm.sliceWidget('Red') | |
rv = rw.sliceView() | |
renderWindow = rv.renderWindow() | |
interactor = renderWindow.GetInteractor() | |
text = vtk.vtkTextActor() | |
text.SetInput('PREOP') | |
textProperty = text.GetTextProperty() | |
textProperty.SetFontSize(10) | |
textProperty.SetColor(1,0,0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
dir = os.path.dirname(r'C:\Users\Alz\Desktop\Sync\Repeat_studies (afedorov@partners.org )\7\RESOURCES\801\Segmentations\*') | |
files = os.listdir(dir) | |
for fileName in files: | |
if "TumorROI_CGTZ_1" in fileName: | |
print fileName | |
filePath = os.path.join(dir,fileName) | |
image = sitk.ReadImage(filePath) | |
filter = sitk.BinaryThresholdImageFilter() | |
filter.SetLowerThreshold(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
ijkToRAS = vtk.vtkMatrix4x4() | |
labelNode = slicer.util.getNode('label') | |
labelNode.GetIJKToRASMatrix(ijkToRAS) | |
centroid = (257.766,264.136,13.6365) | |
rasPoint = ijkToRAS.MultiplyPoint(centroid + (1,))[:3] | |
fn = slicer.vtkMRMLMarkupsFiducialNode() | |
slicer.mrmlScene.AddNode(fn) | |
fn.AddFiducial(rasPoint[0],rasPoint[1],rasPoint[2]) | |
fn.SetNthFiducialLabel(0,'Centroid') |
NewerOlder