Skip to content

Instantly share code, notes, and snippets.

@nbassler
nbassler / bdox.py
Created December 15, 2016 22:52
Simple bdox reader
import sys
import numpy as np
def get_token(f):
"""
returns a tuple with 4 elements:
0: payload id
1: payload dtype string
2: payload number of elements
@nbassler
nbassler / dicomtest.py
Created February 15, 2017 17:20
PyTRiP test for loading dicoms
import pytrip as pt
dcmf = "/local/dicom/pinnacle3-9.9-phantom-imrt"
dcm = pt.dicomhelper.read_dicom_folder(dcmf)
basename = "foobar"
c = pt.CtxCube()
c.read_dicom(dcm)
@nbassler
nbassler / dicomattri.txt
Created February 27, 2017 14:30
DICOM attributes
import pytrip as pt
>>> dir(rts)
['AccessionNumber', 'ApprovalStatus', 'InstanceCreationDate', 'InstanceCreationTime', 'Manufacturer', 'ManufacturerModelName',
'Modality', 'PatientBirthDate', 'PatientID', 'PatientName', 'PatientSex', 'ROIContourSequence',
'RTROIObservationsSequence', 'RefdFrameOfReferenceSequence', 'RefdStudySequence', 'ReferencedFrameOfReferenceSequence',
'ReferencedStudySequence', 'ReferringPhysicianName', 'SOPClassUID', 'SOPInstanceUID', 'SeriesInstanceUID', 'SeriesNumber',
'SoftwareVersions', 'SpecificCharacterSet', 'StationName', 'StructureSetDate', 'StructureSetLabel', 'StructureSetName',
'StructureSetROISequence', 'StructureSetTime', 'StudyDate', 'StudyID', 'StudyInstanceUID', 'StudyTime', '__contains__',
@nbassler
nbassler / dicomdiff.py
Last active February 28, 2017 20:21
Make a nice formatted diff on two dicoms
import pytrip as pt
#dcmf = "/local/dicom/pinnacle3-9.9-phantom-imrt"
dcmf = "/local/dicom/xio-4.33.02-phantom-chest/"
dcm = pt.dicomhelper.read_dicom_folder(dcmf)
dcmf2 = "chestdcm"
dcm2 = pt.dicomhelper.read_dicom_folder(dcmf2)
c1 = dcm['images']
@nbassler
nbassler / pubsub.py
Last active July 30, 2017 14:34
pubsub example
# first line below is necessary only in wxPython 2.8.11.0 since default
# API in this wxPython is pubsub version 1 (expect later versions
# of wxPython to use the kwargs API by default)
from wx.lib.pubsub import setupkwargs
# regular pubsub import
from wx.lib.pubsub import pub
class SomeReceiver(object):
def __init__(self):
@nbassler
nbassler / rebase.txt
Created October 5, 2017 16:16
rebasing
How to rebase:
go to branch to be rebased
$ git rebase master
in case of conflict, fix/edit the file
$ git add file
$ git rebase --continue
repeat until nothing more to be applied.
git push feature/111-mybranch --force
### Keybase proof
I hereby claim:
* I am nbassler on github.
* I am unabdingbar (https://keybase.io/unabdingbar) on keybase.
* I have a public key ASCiRk0ACJmOXLBynm9X7T0gONnCZJIvtqWa3G41RoEiWgo
To claim this, I am signing this object:
@nbassler
nbassler / treeview_test.py
Created April 29, 2018 15:03
PyQt5 TreeView with QAbstractItemModel
"""
Reworked code based on
http://trevorius.com/scrapbook/uncategorized/pyqt-custom-abstractitemmodel/
Adapted to Qt5 and fixed column/row bug.
TODO: handle changing data.
"""
import sys
@nbassler
nbassler / test_ppstruct.c
Created May 24, 2018 15:54
Working with list of pointer to structures in C.
#include <stdio.h>
#include <stdlib.h>
/* gcc test_ppstruct.c -o test_ppstruct -Wall */
struct point {
double x;
double y;
};
@nbassler
nbassler / ptdcm.py
Last active June 21, 2018 12:30
PyTRiP read DICOM
# Example of how to load DICOM data using PyTRiP
# lots of DICOM may be found at SlicerRT
# https://github.com/SlicerRt/SlicerRtData
import pytrip as pt
dp = "/local/dicom/pinnacle3-9.9-phantom-imrt/"
dcm = pt.dicomhelper.read_dicom_dir(dp)