Changes between Initial Version and Version 1 of DicomBrowserDemo


Ignore:
Timestamp:
Nov 5, 2010, 2:34:13 PM (9 years ago)
Author:
flip
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DicomBrowserDemo

    v1 v1  
     1DICOM files come in batches of many files with related
     2metadata in each. We have written a browser that displays an organized
     3summary of this metadata in a tree and also displays a preview of some
     4image files.
     5
     6This browser is also small enough to be a manageable introduction to
     7wxPython. It runs under OS X, Linux and Windows provided
     8wxPython is installed.
     9
     10The browser does just a few things. It allows one to select a directory
     11containing DICOM files, it reads the metadata in each file while providing
     12feedback, and then it displays the files organized in a tree. Finally, when
     13the user chooses a file (or hits cancel), it closes and prints out the user's
     14selection.
     15
     16In order to run it, you'll need to install
     17[http://code.google.com/p/pydicom/ the pydicom library].
     18
     19To run it, `cd` to the directory where `main.py` lives and type
     20`python main.py`.
     21
     22If you don't have any DICOM files with which to test, you can download some
     23from our SVN repository (see the `siemens_dicom_export` directory):
     24https://scion.duhs.duke.edu/svn/sample_data
     25
     26There are three versions, each an improvement on the previous. They live in
     27the orphans SVN
     28repository (https://scion.duhs.duke.edu/svn/orphans/) in the directory
     29`philip`.
     30
     31The simple version is in `orphans/philip/dicom_browser-1.0/`. This version doesn't
     32offer image preview. It also assumes that all DICOM files contain a
     33Siemens-specific tag.
     34
     35A more sophisticated version is in `orphans/philip/dicom_browser-2.0/`.
     36This offers
     37image previewing (for certain files, notably the 55* series in our sample
     38data). It differentiates between Siemens and
     39non-Siemens files, and it makes the dialog easy to subclass for coders who
     40want to change how the dialog constructs the tree item description string.
     41
     42The most recent version in `orphans/philip/dicom_browser-2.1/` adds
     43optional multi-select capability and a subclass-friendly dialog class method
     44that can filter files out of the tree.
     45
     46
     47== The Files ==
     48
     49 * `browser_ui.wxg` is the wxGlade file that describes the user interface.
     50 wxGlade generates `gui_browser.py` for me.
     51 * `dicom_browser.py` subclasses the dialog created in `gui_browser.py`.
     52 * `util_dicom.py` contains the code that talks to the pydicom library and
     53 generates a list of DICOM files for the dialog box.
     54 * `util_dicom_generic.py` contains the DicomFile class which is a generic
     55 container for DICOM files.
     56 * `util_dicom_siemens.py` contains a Siemens-specific subclass of the
     57 DicomFile class.
     58 * `main.py` creates a dummy main window that launches the dialog.
     59 
     60== Technical Notes ==
     61
     62 * It might be tempting to combine `dicom_browser.py` and `util_dicom.py`,
     63 but separating them is useful. It allows the latter to be used with a
     64 dependency on wx. It can be used, for example, on a server to generate
     65 a DICOM file list for a Web application. In that context a wx dependency
     66 would be a headache.
     67 
     68 * Similarly, we want to be careful with integrating `dicom_browser.py` with
     69 our library of wx utilities since it has a depedency on the pydicom library.
     70 We can add it to the library but it should remain a separate file so that
     71 only applications that `import dicom_browser` will have a dependency on
     72 pydicom. The rest of the files in the wx utilities library will remain
     73 free of this depedency.
     74 
     75 * wxPython code is always a little awkward because Python and wxWidgets
     76 follow different naming conventions. Python naming convention uses
     77 `lower_case_variables_names` while wx uses `TitleCaps`.
     78 This results from the fact that
     79 wxWidgets is written in C++ and wxPython is a thin, auto-generated
     80 wrapper around it. In practice, it's unusual to find a Python library that
     81 doesn't follow Python's naming conventions.
     82
     83 In our code we've
     84 introduced a third style (from Java, I think) for naming GUI controls and
     85 event handlers which
     86 is `firstLetterLowerThenUpper` (e.g. the dialog has an event handler called
     87 `onTreeItemActivated()`).
     88 
     89 Using two different naming conventions is
     90 confusing enough; I do not recommend following our example and introducing
     91 a third. In this code, I used firstLetterLowerThenUpper only to be
     92 consistent with our existing libraries.
     93 
     94 * The function `util_dicom.get_files()` is a Python generator which is
     95 something you might not be familiar with. There's a lot of tutorials online
     96 about generators, all of which I find much harder to grasp than the actual code.
     97 Maybe it's just me! Here's one such article:
     98 http://www.ibm.com/developerworks/library/l-pycon.html
     99
     100