MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / run

Method run

ij/src/main/java/ij/plugin/StackPlotter.java:21–91  ·  view source on GitHub ↗
(String arg)

Source from the content-addressed store, hash-verified

19 private int frames = 1;
20
21 public void run(String arg) {
22 ImagePlus imp = IJ.getImage();
23 //Check if Roi is defined
24 if (imp.getRoi() == null) {
25 IJ.error("Stack Plotter", "Line or rectangular selection required");
26 return;
27 }
28 //Check if Image is a Stack
29 int dim = imp.getNDimensions();
30 if (dim < 3) {
31 IJ.error("Stack Plotter","This plugin requires a stack");
32 return;
33 }
34 //Get Stack size
35 int length = 0;
36 if (dim==3)
37 length = imp.getImageStackSize();
38 // Plot stack over frames information, improvement will be to select the dimension to plot over
39 boolean plotFrames = true;
40 if (dim>3) {
41 channel = imp.getChannel();
42 slice = imp.getSlice();
43 frame = imp.getFrame();
44 length = frames = imp.getNFrames();
45 if (dim==4 && length==1) {
46 plotFrames = false;
47 length = imp.getNSlices();
48 }
49 } else
50 slice = imp.getCurrentSlice();
51
52 //Get a profile plot for each frame in the stack
53 //Store min and max value of all Profile across the stack
54 ProfilePlot[] pPlot = new ProfilePlot[length];
55 double ymin = 0;
56 double ymax = 0;
57 for (int i=0; i<length; i++) {
58 if (dim == 3) imp.setPosition(i+1);
59 if (dim > 3) {
60 if (plotFrames)
61 imp.setPosition(channel,slice,i+1);
62 else
63 imp.setPosition(channel,i+1,frame);
64 }
65 pPlot[i] = new ProfilePlot(imp);
66 if (pPlot[i] == null) return;
67 if (pPlot[i].getMin() < ymin) ymin = pPlot[i].getMin();
68 if (pPlot[i].getMax() > ymax) ymax = pPlot[i].getMax();
69 }
70 //Save current Min and Max values of profile plot
71 double pp_min = ProfilePlot.getFixedMin();
72 double pp_max = ProfilePlot.getFixedMax();
73 //Set same Min Max values for all plots
74 ProfilePlot.setMinAndMax(ymin,ymax);
75
76 //Make a profile stack
77 Plot plot = pPlot[0].getPlot();
78 Dimension size = plot.getSize();

Callers

nothing calls this directly

Calls 15

getImageMethod · 0.95
getRoiMethod · 0.95
errorMethod · 0.95
getNDimensionsMethod · 0.95
getImageStackSizeMethod · 0.95
getChannelMethod · 0.95
getSliceMethod · 0.95
getFrameMethod · 0.95
getNFramesMethod · 0.95
getNSlicesMethod · 0.95
getCurrentSliceMethod · 0.95
setPositionMethod · 0.95

Tested by

no test coverage detected