Exemplo n.º 1
0
    def test_dcmread_get_dcmdir_qt(self):

        dirpath = dcmr.get_dcmdir_qt()
        #self.data3d, self.metadata = dcmr.dcm_read_from_dir(self.dcmdir)
        reader = dcmr.DicomReader(dirpath)
        self.data3d = reader.get_3Ddata()
        self.metadata = reader.get_metaData()
Exemplo n.º 2
0
 def setUp(self):
     # self.dcmdir = os.path.join(
     #     path_to_script, '../sample_data/jatra_06mm_jenjatraplus/')
     self.dcmdir = os.path.join(path_to_script, '../sample_data/jatra_5mm')
     # self.data3d, self.metadata = dcmr.dcm_read_from_dir(self.dcmdir)
     reader = dcmr.DicomReader(self.dcmdir)
     self.data3d = reader.get_3Ddata()
     self.metadata = reader.get_metaData()
Exemplo n.º 3
0
    def test_dcmread_select_series(self):

        #dirpath = dcmr.get_dcmdir_qt()
        dirpath = '/home/mjirik/data/medical/data_orig/46328096/'
        #dirpath = dcmr.get_dcmdir_qt()
        #app = QMainWindow()
        reader = dcmr.DicomReader(dirpath,
                                  series_number=55555)  #, #qt_app =app)
        #app.exit()
        self.data3d = reader.get_3Ddata()
        self.metadata = reader.get_metaData()
Exemplo n.º 4
0
    def test_dcmread_series_number(self):

        dcmdir = lisa.dataset.join_sdp('jatra_5mm')
        #dcmdir = '/home/mjirik/data/medical/data_orig/jatra-kma/jatra_5mm/'
        #self.data3d, self.metadata = dcmr.dcm_read_from_dir(self.dcmdir)
        # spravne cislo serie je 7
        reader = dcmr.DicomReader(dcmdir, series_number=7)
        data3d = reader.get_3Ddata()
        metadata = reader.get_metaData()
        self.assertEqual(data3d.shape[2], 512)
        self.assertEqual(metadata['voxelsize_mm'][0], 5)
Exemplo n.º 5
0
    def test_dcmread(self):

        dcmdir = lisa.dataset.join_sdp('jatra_5mm')
        #dcmdir = '/home/mjirik/data/medical/data_orig/jatra-kma/jatra_5mm/'
        #self.data3d, self.metadata = dcmr.dcm_read_from_dir(self.dcmdir)
        reader = dcmr.DicomReader(dcmdir)
        data3d = reader.get_3Ddata()
        metadata = reader.get_metaData()
        #slice size is 512x512
        self.assertEqual(data3d.shape[2], 512)
        # voxelsize depth = 5 mm
        self.assertEqual(metadata['voxelsize_mm'][0], 5)
Exemplo n.º 6
0
    def test_DicomReader_overlay(self):
        #import matplotlib.pyplot as plt

        dcmdir = lisa.dataset.join_sdp('volumetrie/')
        #dcmdir = '/home/mjirik/data/medical/data_orig/jatra-kma/jatra_5mm/'
        #self.data3d, self.metadata = dcmr.dcm_read_from_dir(self.dcmdir)
        reader = dcmr.DicomReader(dcmdir)
        overlay = reader.get_overlay()
        #import pdb; pdb.set_trace()
        #plt.imshow(overlay[1][:,:,0])
        #plt.show()

        self.assertEqual(overlay[1][0, 200, 200], 1)
        self.assertEqual(overlay[1][0, 100, 100], 0)
Exemplo n.º 7
0
    def test_texture_features(self):
        """
        Interactivity is stored to file
        """
        try:
            from pysegbase.seed_editor_qt import QTSeedEditor
        except:
            logger.warning("Deprecated of pyseg_base as submodule")
            from seed_editor_qt import QTSeedEditor
        from PyQt4.QtGui import QApplication
        from skimage.feature import greycomatrix, greycoprops
        import misc
        dcmdir = os.path.join(path_to_script, './../sample_data/jatra_5mm')

        #gcparams = {'pairwiseAlpha':10, 'use_boundary_penalties':True}
        #segparams = {'pairwise_alpha_per':3, 'use_boundary_penalties':True,'boundary_penalties_sigma':200}
        #oseg = organ_segmentation.OrganSegmentation(dcmdir, working_voxelsize_mm = 4, segparams=segparams)
        #oseg.add_seeds_mm([120],[120],[70], label=1, radius=30)
        #oseg.add_seeds_mm([170,220,250],[250,280,200],[70], label=2, radius=30)

        reader = dcmr.DicomReader(dcmdir)  # , qt_app=qt_app)
        data3d = reader.get_3Ddata()
        # normalizace na čísla od nuly do 255
        data3d = data3d / (2**4)
        metadata = reader.get_metaData()
        iparams = {}
        iparams['series_number'] = reader.series_number
        iparams['datadir'] = dcmdir

        working_voxelsize_mm = 2

        voxelsize_mm = np.array(metadata['voxelsize_mm'])
        zoom = voxelsize_mm / working_voxelsize_mm

        PATCH_SIZE = 21
        PATCH_DIST = 15
        shp = data3d.shape
        vx, vy, vz = np.mgrid[0:shp[0] - PATCH_SIZE:PATCH_DIST,
                              0:shp[1] - PATCH_SIZE:PATCH_DIST,
                              0:shp[2] - PATCH_SIZE:8]

        import pdb
        pdb.set_trace()

        feat = np.zeros(vx.shape)
        feat2 = np.zeros(vx.shape)

        #vx = vx.reshape(-1)
        #vy = vy.reshape(-1)
        #vz = vz.reshape(-1)

        #for i in range(0,len(vx)):
        it = np.nditer(vx, flags=['multi_index'])
        while not it.finished:
            vxi = vx[it.multi_index]
            vyi = vy[it.multi_index]
            vzi = vz[it.multi_index]

            patch = data3d[vxi:vxi + PATCH_SIZE, vyi:vyi + PATCH_SIZE, vzi]
            patch = np.squeeze(patch)
            print(it.iterindex, ' - ', vxi, ' ', vyi, ' ', vzi, ' - ',
                  it.multi_index)
            #import pdb; pdb.set_trace()
            glcm = greycomatrix(patch, [5], [0],
                                256,
                                symmetric=True,
                                normed=True)
            dissimilarity = greycoprops(glcm, 'dissimilarity')
            feat[it.multi_index] = dissimilarity
            feat2[it.multi_index] = greycoprops(glcm, 'correlation')
            it.iternext()

        locations = [(474, 291), (440, 433), (466, 18), (462, 236)]

        qt_app = QApplication(sys.argv)
        pyed = QTSeedEditor(feat)
        qt_app.exec_()
        pyed = QTSeedEditor(feat2)
        qt_app.exec_()

        pdb