[Mrtrix-discussion] Writing dicoms?

Donald Tournier d.tournier at brain.org.au
Tue Sep 18 17:22:43 PDT 2012


Hi Finn,

I must say I've never tried it myself, but I've heard of others doing it by
overwriting the data in existing DICOM files. Obviously you can only write
image data, there is no convention for storing tracking results in DICOM as
yet.

If you need to do that, you could probably code up something in MRtrix to
overwrite an existing DICOM set (make a copy of it first..), since there is
an option to open an image as read-write (default is read-only when opening
an existing image). This would rely on a few conditions to actually work.
First, the DICOM can't be mosaic or multi-frame, since this always involves
an explicit load into RAM - you need the image data to remain accessed via
memory-mapping for your modifications to actually have any effect. Second,
the number of DICOM image files must be less than a specific number (128 by
default), otherwise the data will again be explicitly loaded into RAM. You
can change that number easily, it's defined in "lib/image/mapper.cpp", line
35 - just make sure you don't exceed the limit on the number of open files
on your system (1024 on Linux by default). Finally, all details about the
image must match exactly: dimensions, voxel sizes & image transform. The
last two are only important if you need to guarantee alignment with other
DICOM images - which I assume you do. Simplest way to ensure this is to
pass the DICOM image you're interested in writing to as the -template
option for tracks2prob. Also make sure the intensities in the image are in
the range 0-4095: DICOM data are typically stored as 16-bit integers, but
using only 12 bits (don't ask why).

Just to help you on your way, you can start from the following. I haven't
tested it, but should (might?) work as-is... Just copy/paste into a cpp
file in the cmd/ folder (say "cmd/write_to_dicom.cpp") and issue the
./build && ./build install commands as usual.

Would be good if you could report back if you get it to work...
Cheers,

Donald.



#include "app.h"
#include "image/position.h"

using namespace std;
using namespace MR;

SET_VERSION_DEFAULT;

DESCRIPTION = {
  "Copy data into existing DICOM image set, "
  "overwriting existing data.",
  NULL
};

ARGUMENTS = {
  Argument ("input", "input image", "the input image.").type_image_in (),
  Argument ("DICOM", "output DICOM image",
            "the output DICOM image whose data "
            "is to be overwritten.").type_string (),
  Argument::End
};

OPTIONS = { Option::End };

EXECUTE {
  Image::Position in (*argument[0].get_image());
  Image::Object out_obj;
  out_obj.open (argument[1].get_string(), false);

  if (in.ndim() != out_obj.ndim())
    throw Exception ("data set dimensions do not match");
  for (int n = 0; n < in.ndim(); ++n)
    if (in.dim(n) != out_obj.dim(n))
      throw Exception ("data set dimensions do not match");

  Image::Position out (out_obj);

  ProgressBar::init (out.voxel_count(), "overwriting DICOM image...");

  do {
    out.value (in.value());
    ProgressBar::inc();
  } while (out++);

  ProgressBar::done();
}





On 18 September 2012 19:11, Finn Lennartsson <finn.lennartsson at gmail.com>wrote:

> Hi everyone,
>
> We have done some fibre tracking on clinical patients with successful
> results in MRtrix. I would like to add that to the PACS system for
> proper documentation.
>
> Is there anyone of you who have imported (any kind of) tracking
> results into a PACS system? According to our it-staff they can only
> import dicoms into the PACS system (SECTRA PACS). Do you know of any
> way of writing or workaround for writing processed data into dicoms.
> Just importing screenshots should be sufficient in these cases but it
> would be desirable to import more detailed tracking results.
>
> Cheers,
> Finn
> _______________________________________________
> Mrtrix-discussion mailing list
> Mrtrix-discussion at www.nitrc.org
> http://www.nitrc.org/mailman/listinfo/mrtrix-discussion
>



-- 
*Dr Jacques-Donald Tournier
*
Research Fellow

The Florey Institute of Neuroscience and Mental Health
Melbourne Brain Centre - Austin Campus
245 Burgundy Street
Heidelberg  Vic  3084
Ph:  +61 3 9035 7033
Fax:  +61 3 9035 7307
www.florey.edu.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.nitrc.org/pipermail/mrtrix-discussion/attachments/20120919/0021eafa/attachment.html


More information about the Mrtrix-discussion mailing list