Message Boards Message Boards

0
|
5619 Views
|
9 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Get a suitable color scale in Image3D?

Posted 8 years ago

I'm attempting to do some image processing on electron beam simulation results. Specifically I'm trying to visualize the dose profile from a 100x100x100 rectangular mesh.

Creating contour plots for any slice of the cube was simple, but when I try to use Image3D on the data I get one solid color for nearly every non-zero data point no matter how much I fiddle with the opacity and color function options.

Any suggestions on what to do? I've attached a contour slice and my image 3d attempt (temperature map color scheme).

Example dose profile slice, 40 contours Image3D attempt

POSTED BY: Denis Wisniewski
9 Replies
POSTED BY: Marco Thiel

I'm using the MCNP transport code to create the data. I'm using mathematica to analyze it. In my case I used MCNP to track 100 keV electrons through a material and score the energy deposited in each cell. My primary goal was to find the isodose curves at any slice of the data set, which I was able to do. I was hoping to find some interesting results with image3d and was greeted with a red blob.

As far as what the data is like? I'm not sure if I understand your question. Could you be specific? The data is pretty much equivalent to any study on electron beams, so I can only refer you to those. Here's one that shows electron tracks. https://www.researchgate.net/publication/269112923_YW-PolymerPhysics-2013/figures?lo=1

My exact mathematica code I used to create the plots are:

Manipulate[ ListContourPlot[totaldose[[1 ;; 100, 1 ;; 100, m]], PlotRange -> All, Contours -> 40, ColorFunction -> "TemperatureMap"], {m, 1, 100, 1}]

logged = Table[Table[Table[ If[ totaldose[[i, j, k]] == 0, 0, Log10[totaldose[[i, j, k]]] ] , {i, 1, 100}], {j, 1, 100}], {k, 1, 100}]

Image3D[logged]

"totaldose" is my data set. I created the "logged" term because I wasn't sure if the issue was the huge difference in minimum and maximum values (from 10 to 10^7). It didn't seem to matter because the results were essentially identical as if I had just used "totaldose" with image3d. I tried using the slider options on the image to adjust my output. I'm not familiar with image3d.

POSTED BY: Denis Wisniewski

Hi,

without data it is hard to tell what the problem is - so Marcos answer has some background. To have a hopefully appropriate example at hand I created a 3D array of data describing a 3D dose distribution of a 15MeV electron beam in water. Then I get:

enter image description here

(Code and data come as an attachment.) I basically want to communicate that if Image3D does not work for you, then you can use the nice functions ListSliceDensityPlot3D, ListSliceContourPlot3D and friends.

BTW: A simple way to apply a function to the values of a multidimensional array is e.g.:

Attributes[logScale] = Listable;
logScale[dose_] := Piecewise[{{0, dose < 0.001}}, Log[1. + dose]]

logDose3D = logScale[dose3D];

Regards -- Henrik

Attachments:
POSTED BY: Henrik Schachner
Posted 7 years ago

Dear Henrik I have a one .txt file with 4 columns (not .mx file) i want to plot my data same as your plotting. with Image3D and ListSliceCountorPlot3D. can you help me more. the files size is more than 20 MB and i could not attached it.( my mesh cells are 100 (x) *100 (y) * 200 (z) ). The data with 4 columns and 2000,000 rows.

Best regards

Saeid

POSTED BY: saeid M

Dear Saeid,

to give an unspecific answer to your unspecific question: To begin with I would try to create a 3D array from your data. To be able to give more help, one needs at least a small but representative sample of your data.

Regards -- Henrik

POSTED BY: Henrik Schachner
Posted 7 years ago

Dear Saeid,

to give an unspecific answer to your unspecific question: To begin with I would try to create a 3D array from your data. To be able to give more help, one needs at least a small but representative sample of your data.

Regards -- Henrik

POSTED BY: saeid M
Posted 7 years ago

Dear Henrik, Thank you very much

yes, I attached the example data with 5050200 pixels.

Best regards

Attachments:
POSTED BY: saeid M

Dear Saeid,

the first three rows of your data appear to be the coordinates and are Integers - excellent! (This is why I wished to see a sample!) Try this:

ClearAll["Global`*"]

textData = Import[" < your file > ", "Table"];
(* dimenstions taken from the last row: *)
dims = Most[Last@textData] + 1
(* generate empty array: *)
data3D = ConstantArray[0, dims];
(* values are filled in: *)    
Set[data3D[[#1 + 1, #2 + 1, #3 + 1]], #4] & @@@ textData;

Attributes[logScale] = Listable;
logScale[data_] := Piecewise[{{0, data < 0.001}}, Log[1. + data]];

logData3D = logScale[data3D];

Now you can do e.g.:

enter image description here

Regards -- Henrik

POSTED BY: Henrik Schachner
Posted 7 years ago

Dear Henrik

Thanks a lot for your fast reply and very useful help!

Best wishes

POSTED BY: saeid M
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract