Thanks Stefan,
This all works now. Quite a bit of xml-parsing and searching. I threshold
the mask image between 0 and 1, whereby one is set to 255 giving me a white
mask on a black background.
Please note that there is an error in the index.xml formatting:
http://stackoverflow.com/questions/38853644/python-xml-parseerror-junk-after
-document-element
I will report it as a bug.
Jan
From: Kislinskiy, Stefan [mailto:s.kislins...@dkfz-heidelberg.de]
Sent: Tuesday, August 09, 2016 15:00
To: Jan de Lange; mitk-users@lists.sourceforge.net
Subject: RE: [mitk-users] Reading MITK files with Python and openCV
Hi Jan,
(A) the information you are looking for is in the index.xml file of the
ZIP archive. Your segmentation nodes have a source tag referencing their
reference images in that file.
(B) The mask image is a 8 or 16 bit image but in case you have just a
single segmentation in an image, most pixels are either 0 (background) or 1
(foreground). Rendering such an image as a normal greyscale image isn't a
good idea, as you can't really see the difference between these two very
similar grey values. Either you process your images for example by
multiplying it with 2^(bit depth)-1 which will result in grey values 0
(black) and 255 (white) for an 8 bit image, or you use a lookup table, which
maps values 0 and 1 to distinguishable colors.
(C) See (A). All other xml files contain the data node properties. If you
have no idea what data node properties are: There is a "Properties" plugin
in the Workbench (icon is a magnifier hovering over a list), that you can
use to get an idea about all the information stored as properties.
Best,
Stefan
From: Jan de Lange [mailto:janfdela...@gmail.com]
Sent: Dienstag, 9. August 2016 14:22
To: mitk-users@lists.sourceforge.net
Subject: [mitk-users] Reading MITK files with Python and openCV
I am trying to read the .mitk files into Python to extract the image mask
files with annotations created in the MITK editor.
The .mitk files are in fact zipped files, so these can be read with Pyhton.
In my case the .mitk zip file contains (a lot of) 3 types of files:
1) bmdaaa - type files without extension. These appear to be .xml
format type files.
2) bndaaa_00000372.nrrd - type files. These are .nrrd type files that
can be read into Python using pynrrd module found here:
https://github.com/mhe/pynrrd
3) bubaaa_Bolus.nrrd - type files. These also are .nrrd files.
It appears that files of type 2) are the image files that have been loaded
into the MITK editor. The "_00000372" part is the file name of the original
imported (.tif) file.
I think that files of type 3) contain the annotation information, because
the "_Bolus" part is the name of the segmentation layer given in the MITK
editor.
I do not know how this annotation file is linked to the image by means of
file naming in the .mitk file, as all filenames are unique.
A) So how do I know which annotation file belongs to which image?
The shape of the annotation file is (width, height, 1L), so it appears to be
a gray scale image.
To plot it properly with Python and openCV I need to swap rows and columns,
because openCV uses (height, width, color). Not sure where the difference
originates.
Swapping rows and columns as described allows showing the mask image with
openCV, however, it is fully black. So for some reason the mask is not shown
(assuming it is there).
B) How do I show the mask in this image?
File type 2) with the original image, has a format of (3L, width, height),
so it appears to be a color image.
To plot this image properly in openCV, columns and rows need to be swapped,
but also, the color data must be moved to the 3-rd dimension as openCV
expects (height, width, color).
Swapping information accordingly plots the original image correctly.
C) What is the purpose of the .xml files? What information is of
relevance for my purpose of extracting the mask / annotation files from the
.mitk file?
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users