How to ADD DICOM slices into Voxel 3d grid

37 views
Skip to first unread message

Yahia Walid

unread,
Dec 26, 2013, 9:34:43 AM12/26/13
to field...@googlegroups.com
Hi , I need to load slices (almost 500 dcm image file ) in to a grid of voxels , how do I do that using Field3D???

Magnus Wrenninge

unread,
Dec 26, 2013, 3:45:19 PM12/26/13
to field...@googlegroups.com
Hi, 

I'm not personally familiar with the DICOM API, but this is roughly the way you'd set up the Field3D data structure:

int xDim = [dicom slice x resolution];
int yDim = [dicom slice y resolution];
int zDim = [number of dicom slices];

DenseField<float>::Ptr dense(new DenseField<float>);
DenseField<float> *rawPtr = dense.get();

dense->name = "dicom_data";
dense->attribute = "density";

dense->setSize(Imath::V3i(xDim, yDim, zDim));

Then, you would traverse each slice and copy each pixel value into a voxel:

for (int k = 0; k < zDim; ++k) {
  for (int j = 0; j < yDim; ++j) {
    for (int i = 0; i < xDim; ++i) {
      rawPtr->fastValue(i, j, k) = dicomSlices[z].pixel(i, j);
    }
  }
}

Finally, to write the data to disk:

Field3DOutputFile out;
out.create("filename.f3d");
out.writeScalarLayer<float>(dense);

I hope that helps,


Magnus


On Thu, Dec 26, 2013 at 6:34 AM, Yahia Walid <geek.k...@gmail.com> wrote:
Hi , I need to load slices (almost 500 dcm image file ) in to a grid of voxels , how do I do that using Field3D???

--
You received this message because you are subscribed to the Google Groups "Field3D dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to field3d-dev...@googlegroups.com.
To post to this group, send email to field...@googlegroups.com.
Visit this group at http://groups.google.com/group/field3d-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Yahia Walid

unread,
Dec 27, 2013, 9:01:16 AM12/27/13
to field...@googlegroups.com


Le jeudi 26 décembre 2013 15:34:43 UTC+1, Yahia Walid a écrit :
Hi , I need to load slices (almost 500 dcm image file ) in to a grid of voxels , how do I do that using Field3D???
 what about opacity man? and how do I specify the path of my numerous slices automaticly , i have like 500 of them which means i can't do it manuelly , and thanks for the reply man . 

Magnus Wrenninge

unread,
Dec 30, 2013, 4:19:03 PM12/30/13
to field...@googlegroups.com
Opacity would be no different, just store it directly, but change dense->attribute = "opacity" to be explicit about what's being stored. 

As far as indexing your slices, I don't know enough about your file naming and the DICOM API, but I imagine it would be something like this:

for (int k = 0; k < zDim; ++k) {
  std::stringstream filename;
  filename << "/my/root/path/slice." << k << ".dicom";
  dicomSlices[k] = readDicomFile(filename.str());
}

Magnus


--
Reply all
Reply to author
Forward
0 new messages