1 package com.github.celldynamics.quimp.plugin.qanalysis;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8
9 import com.github.celldynamics.quimp.Outline;
10 import com.github.celldynamics.quimp.OutlineHandler;
11 import com.github.celldynamics.quimp.QColor;
12 import com.github.celldynamics.quimp.QuimpException;
13 import com.github.celldynamics.quimp.Vert;
14 import com.github.celldynamics.quimp.filesystem.FileExtensions;
15 import com.github.celldynamics.quimp.filesystem.IQuimpSerialize;
16 import com.github.celldynamics.quimp.filesystem.converter.FormatConverter;
17 import com.github.celldynamics.quimp.geom.ExtendedVector2d;
18 import com.github.celldynamics.quimp.geom.filters.OutlineProcessor;
19 import com.github.celldynamics.quimp.utils.QuimPArrayUtils;
20 import com.github.celldynamics.quimp.utils.QuimpToolsCollection;
21
22 import ij.IJ;
23 import ij.ImagePlus;
24 import ij.process.ColorProcessor;
25 import ij.process.ImageProcessor;
26
27
28
29
30
31
32
33
34
35
36
37 public class STmap implements IQuimpSerialize {
38
39
40
41
42 public static Logger LOGGER = LoggerFactory.getLogger(STmap.class.getName());
43
44
45
46
47
48
49 public static final int MOTILITY = 1;
50
51
52
53
54
55 public static final int CONVEXITY = 2;
56
57
58
59
60
61 public static final int ORIGIN = 4;
62
63
64
65
66
67 public static final int COORD = 8;
68
69
70
71
72
73 public static final int XMAP = 16;
74
75
76
77
78
79 public static final int YMAP = 32;
80
81
82
83
84
85 public static final int FLU1 = 64;
86
87
88
89
90
91 public static final int FLU2 = 128;
92
93
94
95
96
97 public static final int FLU3 = 256;
98
99
100
101
102
103 public static final int ALLFLU = FLU1 | FLU2 | FLU3;
104
105
106
107 public static final int ALLMAPS = MOTILITY | CONVEXITY | ORIGIN | COORD | XMAP | YMAP | ALLFLU;
108
109
110
111
112
113
114
115
116
117
118
119
120 private double[][] coordMap;
121
122
123
124
125
126
127
128
129
130 private double[][] originMap;
131
132
133
134
135
136
137
138
139 private double[][] xMap;
140
141
142
143
144
145
146
147
148 private double[][] yMap;
149
150
151
152
153
154
155
156
157
158
159
160
161 private double[][] motMap;
162
163
164
165
166 transient int[] migColor;
167
168
169
170
171 transient float[] migPixels;
172
173
174
175 public FluoMap[] fluoMaps;
176
177
178
179
180
181 private double[][] convMap;
182
183
184
185
186 transient int[] convColor;
187
188
189
190
191 transient ImagePlus migImP;
192 transient ImagePlus fluImP;
193 transient ImagePlus convImP;
194
195
196
197
198
199
200
201 transient OutlineHandler oh;
202
203
204
205
206
207
208 private int res;
209
210
211
212 private int T;
213 private double mapPixelHeight = 1;
214 private double mapPixelWidth = 1;
215
216 private transient Qp params;
217
218
219
220
221
222 public STmap() {
223 this.fluoMaps = new FluoMap[3];
224 this.params = new Qp();
225 }
226
227
228
229
230
231
232
233
234
235
236 public STmapldynamics/quimp/plugin/qanalysis/STmap.html#STmap">STmap(final STmap src) {
237 this();
238 this.coordMap = QuimPArrayUtils.copy2darray(src.coordMap, null);
239 this.originMap = QuimPArrayUtils.copy2darray(src.originMap, null);
240 this.xMap = QuimPArrayUtils.copy2darray(src.xMap, null);
241 this.yMap = QuimPArrayUtils.copy2darray(src.yMap, null);
242 this.motMap = QuimPArrayUtils.copy2darray(src.motMap, null);
243 this.convMap = QuimPArrayUtils.copy2darray(src.convMap, null);
244 this.res = src.res;
245 this.T = src.T;
246 this.mapPixelHeight = src.mapPixelHeight;
247 this.mapPixelWidth = src.mapPixelWidth;
248 this.fluoMaps = new FluoMap[src.fluoMaps.length];
249 for (int i = 0; i < src.fluoMaps.length; i++) {
250 this.fluoMaps[i] = new FluoMap(src.fluoMaps[i]);
251 }
252 try {
253 this.params = (Qp) src.params.clone();
254 } catch (CloneNotSupportedException e) {
255 e.printStackTrace();
256 }
257
258 }
259
260
261
262
263
264
265
266
267
268 public STmap(OutlineHandler o, int r, Qp params) {
269 this();
270 this.params = params;
271 mapPixelHeight = 1;
272 mapPixelWidth = 1.0d / r;
273 res = r;
274 oh = o;
275 T = oh.getSize();
276
277 coordMap = new double[T][res];
278 originMap = new double[T][res];
279 xMap = new double[T][res];
280 yMap = new double[T][res];
281
282 motMap = new double[T][res];
283 migColor = new int[T * res];
284 migPixels = new float[T * res];
285
286
287
288
289 convMap = new double[T][res];
290 convColor = new int[T * res];
291
292
293 Vert v = oh.indexGetOutline(0).getHead();
294 for (int i = 0; i < 3; i++) {
295 fluoMaps[i] = new FluoMap(T, res, i + 1);
296 System.out.println("flou in v: " + v.fluores[i].intensity);
297 if (v.fluores[i].intensity == -2) {
298 IJ.log("No fluorescence data for channel " + (i + 1));
299 fluoMaps[i].setEnabled(false);
300 }
301 }
302
303 generate();
304 saveConvMotImages();
305 }
306
307
308
309
310 private void generate() {
311
312 this.calcCurvature();
313 Vert zeroVert;
314 Vert v;
315 String migColorMap = "rwb";
316
317 double fraction;
318 double intMig;
319 double intFlu;
320 double intConv;
321 double target;
322 double actualTarget;
323 QColor color;
324 int pn;
325 Vert fhead;
326 Vert chead;
327
328 double step = 1.0d / res;
329
330
331
332
333
334
335
336
337
338
339 double origin = 0;
340 int frame;
341
342 for (int tt = 0; tt < T; tt++) {
343
344 frame = tt + oh.getStartFrame();
345
346 pn = tt * res;
347
348
349 fhead = oh.getStoredOutline(frame).findFirstNode('f');
350 chead = oh.getStoredOutline(frame).findFirstNode('c');
351
352
353
354 if (tt == 0) {
355
356 zeroVert = chead;
357 fraction = 0;
358 origin = 0;
359 } else {
360
361
362 zeroVert = closestFloor(oh.getStoredOutline(frame), origin, 'f', fhead);
363
364
365
366 fraction = ffraction(zeroVert, origin, fhead);
367
368
369
370
371 origin = interpCoord(zeroVert, fraction, chead);
372
373 }
374 target = origin;
375
376 intMig = interpolate(zeroVert.distance, zeroVert.getNext().distance, fraction);
377 motMap[tt][0] = intMig;
378 color = QColor.erColorMap2(migColorMap, intMig, oh.migLimits[0], oh.migLimits[1]);
379 migColor[pn] = color.getColorInt();
380 migPixels[pn] = (float) intMig;
381
382
383 for (int i = 0; i < 3; i++) {
384 if (fluoMaps[i].isEnabled()) {
385 if (zeroVert.fluores[i].intensity == -2) {
386 IJ.log("ERROR: There are missing fluoresecne values! Run ANA");
387 return;
388 }
389 intFlu = interpolate(zeroVert.fluores[i].intensity,
390 zeroVert.getNext().fluores[i].intensity, fraction);
391 fluoMaps[i].fill(tt, 0, pn, intFlu, oh.fluLims[i][1]);
392 }
393 }
394
395
396
397
398
399
400
401
402 intConv = interpolate(zeroVert.curvatureSum, zeroVert.getNext().curvatureSum, fraction);
403 convMap[tt][0] = intConv;
404 color = QColor.erColorMap2("rbb", intConv, oh.curvLimits[0], oh.curvLimits[1]);
405 convColor[pn] = color.getColorInt();
406
407 coordMap[tt][0] = origin;
408 originMap[tt][0] = interpFCoord(zeroVert, fraction, fhead);
409 xMap[tt][0] = interpolate(zeroVert.getX(), zeroVert.getNext().getX(), fraction);
410 yMap[tt][0] = interpolate(zeroVert.getY(), zeroVert.getNext().getY(), fraction);
411
412 if (target >= 1 || target < 0) {
413 System.out.println("target out of range: " + target);
414 }
415
416 for (int p = 1; p < res; p++) {
417 pn = (tt * res) + p;
418 target += step;
419 actualTarget = (target >= 1) ? target - 1 : target;
420
421 coordMap[tt][p] = actualTarget;
422
423 v = closestFloor(oh.getStoredOutline(frame), actualTarget, 'c', chead);
424 fraction = cfraction(v, actualTarget, chead);
425
426 originMap[tt][p] = interpFCoord(v, fraction, fhead);
427 xMap[tt][p] = interpolate(v.getX(), v.getNext().getX(), fraction);
428 yMap[tt][p] = interpolate(v.getY(), v.getNext().getY(), fraction);
429
430 intMig = interpolate(v.distance, v.getNext().distance, fraction);
431 motMap[tt][p] = intMig;
432 color = QColor.erColorMap2(migColorMap, intMig, oh.migLimits[0], oh.migLimits[1]);
433 migColor[pn] = color.getColorInt();
434 migPixels[pn] = (float) intMig;
435
436 for (int i = 0; i < 3; i++) {
437 if (fluoMaps[i].isEnabled()) {
438 intFlu = interpolate(v.fluores[i].intensity, v.getNext().fluores[i].intensity,
439 fraction);
440 fluoMaps[i].fill(tt, p, pn, intFlu, oh.fluLims[i][1]);
441 }
442 }
443
444
445
446
447
448
449
450 intConv = interpolate(v.curvatureSum, v.getNext().curvatureSum, fraction);
451 convMap[tt][p] = intConv;
452 color = QColor.erColorMap2("rbb", intConv, oh.curvLimits[0], oh.curvLimits[1]);
453 convColor[pn] = color.getColorInt();
454
455 }
456
457 }
458
459 migImP = map2ImagePlus("motility_map", new ColorProcessor(res, T, migColor));
460 convImP = map2ImagePlus("convexity_map", new ColorProcessor(res, T, convColor));
461 migImP.show();
462 convImP.show();
463
464
465
466 if (params.Build3D) {
467
468 STMap3Ds/quimp/plugin/qanalysis/STMap3D.html#STMap3D">STMap3D map3d = new STMap3D(xMap, yMap, migColor);
469 map3d.build();
470 map3d.toOrigin(oh.indexGetOutline(0).getCentroid());
471 map3d.scale(0.05f);
472 map3d.write(new File("/tmp/cell_02.wrl"));
473
474
475 STMap3Duimp/plugin/qanalysis/STMap3D.html#STMap3D">STMap3D map3dCur = new STMap3D(xMap, yMap, convColor);
476 map3dCur.build();
477 map3dCur.toOrigin(oh.indexGetOutline(0).getCentroid());
478 map3dCur.scale(0.05f);
479 map3dCur.write(new File("/tmp/cell_02_cur.wrl"));
480 }
481
482
483
484 for (int i = 0; i < 3; i++) {
485 if (!fluoMaps[i].isEnabled()) {
486 continue;
487 }
488
489 fluImP = IJ.createImage(params.filename + "_fluoCH" + fluoMaps[i].getChannel(), "8-bit black",
490 res, T, 1);
491 fluImP.getProcessor().setPixels(fluoMaps[i].getColours());
492 resize(fluImP);
493 setCalibration(fluImP);
494 fluImP.show();
495
496 try {
497 Thread.sleep(500);
498 } catch (Exception e) {
499 ;
500 }
501
502 IJ.doCommand("Red");
503 String tmpfilename = FileExtensions.fluomapFileExt.replaceFirst("%",
504 Integer.toString(fluoMaps[i].getChannel()));
505 IJ.saveAs(fluImP, "tiff",
506 params.outFile.getParent() + File.separator + params.filename + tmpfilename);
507 }
508
509
510
511 if (QuimPArrayUtils.sumArray(migColor) == 0) {
512 IJ.showMessage("ECMM data is missing (or corrupt), and is needed for building accurate maps.+"
513 + "\nPlease run ECMM (fluorescence data will be lost)");
514 }
515
516
517
518
519
520
521 }
522
523
524
525
526
527
528
529 public void saveMaps(int maps) throws QuimpException {
530 try {
531 if ((maps & MOTILITY) == MOTILITY) {
532 File f = new File(params.outFile.getPath() + FileExtensions.motmapFileExt);
533 QuimPArrayUtils.arrayToFile(motMap, ",", f);
534 LOGGER.info("\tSaved motility map at: " + f.getAbsolutePath());
535 }
536 if ((maps & CONVEXITY) == CONVEXITY) {
537 File f = new File(params.outFile.getPath() + FileExtensions.convmapFileExt);
538 QuimPArrayUtils.arrayToFile(convMap, ",", f);
539 LOGGER.info("\tSaved convexity map at: " + f.getAbsolutePath());
540 }
541 if ((maps & ORIGIN) == ORIGIN) {
542 File f = new File(params.outFile.getPath() + FileExtensions.originmapFileExt);
543 QuimPArrayUtils.arrayToFile(originMap, ",", f);
544 LOGGER.info("\tSaved origin map at: " + f.getAbsolutePath());
545 }
546 if ((maps & COORD) == COORD) {
547 File f = new File(params.outFile.getPath() + FileExtensions.coordmapFileExt);
548 QuimPArrayUtils.arrayToFile(coordMap, ",", f);
549 LOGGER.info("\tSaved coord map at: " + f.getAbsolutePath());
550 }
551 if ((maps & XMAP) == XMAP) {
552 File f = new File(params.outFile.getPath() + FileExtensions.xmapFileExt);
553 QuimPArrayUtils.arrayToFile(xMap, ",", f);
554 LOGGER.info("\tSaved x map at: " + f.getAbsolutePath());
555 }
556 if ((maps & YMAP) == YMAP) {
557 File f = new File(params.outFile.getPath() + FileExtensions.ymapFileExt);
558 QuimPArrayUtils.arrayToFile(yMap, ",", f);
559 LOGGER.info("\tSaved y map at: " + f.getAbsolutePath());
560 }
561 if ((maps & FLU1) == FLU1) {
562 saveFluoroMap(0);
563 }
564 if ((maps & FLU2) == FLU2) {
565 saveFluoroMap(1);
566 }
567 if ((maps & FLU3) == FLU3) {
568 saveFluoroMap(2);
569 }
570 } catch (NullPointerException np) {
571 LOGGER.debug(np.getMessage(), np);
572 throw new QuimpException("Can not save map. Input array does not exist: " + np.getMessage());
573 } catch (IOException e1) {
574 IJ.error("Could not write Map file:\n " + e1.getMessage());
575 LOGGER.debug(e1.getMessage(), e1);
576 throw new QuimpException(e1);
577 } catch (Exception e) {
578 LOGGER.debug(e.getMessage(), e);
579 throw new QuimpException(e);
580 }
581 }
582
583
584
585
586
587
588
589
590 private void saveFluoroMap(int index) throws IOException {
591 if (!fluoMaps[index].isEnabled()) {
592 LOGGER.debug("Selected map " + (index + 1) + " is not enabled");
593 } else {
594 String tmpfilename = FileExtensions.fluomapFileExt.replaceFirst("%",
595 Integer.toString(fluoMaps[index].getChannel()));
596 File f = new File(params.outFile.getPath() + tmpfilename);
597 QuimPArrayUtils.arrayToFile(fluoMaps[index].getMap(), ",", f);
598 LOGGER.info("\tSaved fluoro map at: " + f.getAbsolutePath());
599 }
600 }
601
602
603
604
605 private void saveConvMotImages() {
606
607 IJ.saveAs(migImP, "tiff", params.outFile.getParent() + File.separator + params.filename
608 + FileExtensions.motimageFileExt);
609 IJ.saveAs(convImP, "tiff", params.outFile.getParent() + File.separator + params.filename
610 + FileExtensions.convimageFileExt);
611 }
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642 public ImagePlus map2ImagePlus(String name, ImageProcessor imp) {
643 ImagePlus ret = new ImagePlus(name, imp);
644 resize(ret);
645 setCalibration(ret);
646 return ret;
647 }
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674 public ImagePlus map2ColorImagePlus(String name, String palette, double[][] map, double min,
675 double max) {
676 int[] migColor = new int[map.length * map[0].length];
677 int pn = 0;
678 int t = map.length;
679 int res = map[0].length;
680 for (int r = 0; r < t; r++) {
681 for (int c = 0; c < res; c++) {
682
683 QColor color = QColor.erColorMap2(palette, map[r][c], min, max);
684 migColor[pn++] = color.getColorInt();
685 }
686 }
687 return map2ImagePlus(name, new ColorProcessor(res, t, migColor));
688 }
689
690 private Vert closestFloor(Outline o, Verts="jxr_keyword">double target, char c, Vert head) {
691
692
693 Vert v = head;
694 double coord;
695 double coordNext;
696 do {
697 coord = (c == 'f') ? v.fCoord : v.coord;
698 coordNext = (c == 'f') ? v.getNext().fCoord : v.getNext().coord;
699
700 if (coord == target) {
701 break;
702 }
703 if (coordNext > target && coord < target) {
704 break;
705 }
706
707 v = v.getNext();
708 } while (v.getNext().getTrackNum() != head.getTrackNum());
709
710
711 return v;
712 }
713
714 private double cfraction(Vertuimp/Vert.html#Vert">Vert v, double target, Vert head) {
715
716 double v2coord;
717 if (v.getNext().getTrackNum() == head.getTrackNum()) {
718 v2coord = v.getNext().coord + 1;
719 target = (target > v.coord) ? target : target + 1;
720 } else {
721 v2coord = v.getNext().coord;
722 }
723
724 double frac = (target - v.coord) / (v2coord - v.coord);
725
726
727 if (frac >= 1) {
728 frac = frac - 1;
729 LOGGER.warn("WARNING- frac corrected: " + frac);
730 }
731 if (frac > 1 || frac < 0) {
732 LOGGER.warn("!WARNING, frac out of range:" + frac);
733 }
734 return frac;
735 }
736
737 private double ffraction(Vertuimp/Vert.html#Vert">Vert v, double target, Vert head) {
738
739 double v2coord;
740 if (v.getNext().getTrackNum() == head.getTrackNum()) {
741
742 v2coord = v.getNext().fCoord + 1;
743 target = (target > v.fCoord) ? target : target + 1;
744 } else {
745 v2coord = v.getNext().fCoord;
746 }
747 double frac = (target - v.fCoord) / (v2coord - v.fCoord);
748
749
750
751 if (frac >= 1) {
752 frac = frac - 1;
753 LOGGER.warn("WARNING- frac corrected: " + frac);
754 }
755 if (frac > 1 || frac < 0) {
756 LOGGER.warn("WARNING, frac out of range:" + frac);
757 }
758
759 if (Double.isNaN(frac)) {
760 LOGGER.warn("WARNING, frac is nan:" + frac);
761 System.out.println("\tffraction: |v:" + v.fCoord + "|v2:" + v2coord + "|tar:" + target
762 + "|frac:" + frac);
763 frac = 0.5;
764 }
765 return frac;
766 }
767
768 private double interpCoord(Vert/quimp/Vert.html#Vert">Vert v, double frac, Vert head) {
769 double v2Coord = (v.getNext().getTrackNum() == head.getTrackNum()) ? v.getNext().coord + 1
770 : v.getNext().coord;
771 double dis = v2Coord - v.coord;
772 double targ = v.coord + (dis * frac);
773
774 if (targ >= 1) {
775 targ += -1;
776 }
777
778 if (targ < 0) {
779 LOGGER.error("ERROR: target less than zero");
780 }
781
782 return targ;
783 }
784
785 private double interpFCoord(Vert/quimp/Vert.html#Vert">Vert v, double frac, Vert head) {
786 double v2Coord = (v.getNext().getTrackNum() == head.getTrackNum()) ? v.getNext().fCoord + 1
787 : v.getNext().fCoord;
788 double dis = v2Coord - v.fCoord;
789 double targ = v.fCoord + (dis * frac);
790
791 if (targ >= 1) {
792 targ += -1;
793 }
794
795 if (targ < 0) {
796 LOGGER.error("ERROR: target less than zero");
797 }
798
799 return targ;
800 }
801
802 private double interpolate(double v1, double v2, double frac) {
803 return v1 + ((v2 - v1) * frac);
804 }
805
806
807
808
809 private void calcCurvature() {
810
811 Outline o;
812 Vert v;
813
814 oh.curvLimits = new double[2];
815
816 for (int f = oh.getStartFrame(); f <= oh.getEndFrame(); f++) {
817 o = oh.getStoredOutline(f);
818 if (o == null) {
819 IJ.log("ERROR: Outline at frame " + f + " is empty");
820 continue;
821 }
822
823
824 o.updateCurvature();
825
826
827 v = o.getHead();
828 do {
829 v.curvatureSmoothed = v.curvatureLocal;
830 v.curvatureSum = v.curvatureLocal;
831 v = v.getNext();
832 } while (!v.isHead());
833
834 new OutlineProcessor<Outline>(o).averageCurvature(params.avgCov).sumCurvature(params.sumCov);
835
836
837
838
839
840 v = o.getHead();
841 if (f == oh.getStartFrame()) {
842 oh.curvLimits[1] = v.curvatureSum;
843 oh.curvLimits[0] = v.curvatureSum;
844 }
845 do {
846 if (v.curvatureSum > oh.curvLimits[1]) {
847 oh.curvLimits[1] = v.curvatureSum;
848 }
849 if (v.curvatureSum < oh.curvLimits[0]) {
850 oh.curvLimits[0] = v.curvatureSum;
851 }
852 v = v.getNext();
853 } while (!v.isHead());
854
855
856
857 }
858
859
860
861 oh.curvLimits = QuimpToolsCollection.setLimitsEqual(oh.curvLimits);
862
863
864 }
865
866 @Deprecated
867 private void averageCurvature(Outline o) {
868
869 Vert v;
870 Vert tmpV;
871 double totalCur;
872 double distance;
873 int count;
874
875
876 if (params.avgCov > 0) {
877
878 v = o.getHead();
879 do {
880
881 totalCur = v.curvatureLocal;
882 count = 1;
883
884
885
886 tmpV = v.getPrev();
887 distance = 0;
888 do {
889 distance += ExtendedVector2d.lengthP2P(tmpV.getNext().getPoint(), tmpV.getPoint());
890 totalCur += tmpV.curvatureLocal;
891 count++;
892 tmpV = tmpV.getPrev();
893 } while (distance < params.avgCov / 2);
894
895
896 distance = 0;
897 tmpV = v.getNext();
898 do {
899 distance += ExtendedVector2d.lengthP2P(tmpV.getPrev().getPoint(), tmpV.getPoint());
900 totalCur += tmpV.curvatureLocal;
901 count++;
902 tmpV = tmpV.getNext();
903 } while (distance < params.avgCov / 2);
904
905 v.curvatureSmoothed = totalCur / count;
906
907 v = v.getNext();
908 } while (!v.isHead());
909 }
910 }
911
912
913
914
915
916
917 @Deprecated
918 private void sumCurvature(Outline o) {
919
920 Vert v;
921 Vert tmpV;
922 double totalCur;
923 double distance;
924
925 if (params.sumCov > 0) {
926 LOGGER.trace("summing curv");
927 v = o.getHead();
928 do {
929
930 totalCur = v.curvatureSmoothed;
931
932
933 tmpV = v.getPrev();
934 distance = 0;
935 do {
936 distance += ExtendedVector2d.lengthP2P(tmpV.getNext().getPoint(), tmpV.getPoint());
937 totalCur += tmpV.curvatureSmoothed;
938 tmpV = tmpV.getPrev();
939 } while (distance < params.sumCov / 2);
940
941
942 distance = 0;
943 tmpV = v.getNext();
944 do {
945 distance += ExtendedVector2d.lengthP2P(tmpV.getPrev().getPoint(), tmpV.getPoint());
946 totalCur += tmpV.curvatureSmoothed;
947 tmpV = tmpV.getNext();
948 } while (distance < params.sumCov / 2);
949
950 v.curvatureSum = totalCur;
951
952 v = v.getNext();
953 } while (!v.isHead());
954 }
955
956 }
957
958
959
960
961
962
963
964
965
966
967 public int getVerticalResolution() {
968 double vertRes = Math.ceil((double) res / (double) T);
969 return (int) (T * vertRes);
970 }
971
972
973
974
975
976
977 public void resize(ImagePlus imp) {
978 if (T >= res * 0.9) {
979 return;
980 }
981 ImageProcessor ip = imp.getProcessor();
982
983 ip.setInterpolationMethod(ImageProcessor.NONE);
984
985 double vertRes = Math.ceil((double) res / (double) T);
986 mapPixelHeight = 1.0d / vertRes;
987 vertRes = T * vertRes;
988
989 ip = ip.resize(res, (int) vertRes);
990 imp.setProcessor(ip);
991
992 }
993
994
995
996
997
998
999 public void setCalibration(ImagePlus imp) {
1000 imp.getCalibration().setUnit("frames");
1001 imp.getCalibration().pixelHeight = mapPixelHeight;
1002 imp.getCalibration().pixelWidth = mapPixelWidth;
1003 LOGGER.debug("PixelWidth=" + mapPixelWidth + " PixelHeight=" + mapPixelHeight);
1004 }
1005
1006
1007
1008
1009
1010
1011
1012
1013 public int getRes() {
1014 return res;
1015 }
1016
1017
1018
1019
1020
1021
1022
1023
1024 public int getT() {
1025 return T;
1026 }
1027
1028
1029
1030
1031
1032
1033 public double[][] getxMap() {
1034 return xMap;
1035 }
1036
1037
1038
1039
1040
1041
1042
1043
1044 public void setxMap(double[][] xmap) {
1045 this.xMap = xmap;
1046 T = xmap.length;
1047 res = xmap[0].length;
1048 }
1049
1050
1051
1052
1053
1054
1055 public double[][] getyMap() {
1056 return yMap;
1057 }
1058
1059
1060
1061
1062
1063
1064
1065
1066 public void setyMap(double[][] ymap) {
1067 this.yMap = ymap;
1068 T = ymap.length;
1069 res = ymap[0].length;
1070 }
1071
1072
1073
1074
1075
1076
1077 public double[][] getCoordMap() {
1078 return coordMap;
1079 }
1080
1081
1082
1083
1084
1085
1086
1087
1088 public void setCoordMap(double[][] coordMap) {
1089 this.coordMap = coordMap;
1090 T = coordMap.length;
1091 res = coordMap[0].length;
1092 }
1093
1094
1095
1096
1097
1098
1099 public double[][] getOriginMap() {
1100 return originMap;
1101 }
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111 public void setOriginMap(double[][] originMap) {
1112 this.originMap = originMap;
1113 T = originMap.length;
1114 res = originMap[0].length;
1115 }
1116
1117
1118
1119
1120
1121
1122 public double[][] getMotMap() {
1123 return motMap;
1124 }
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134 public void setMotMap(double[][] motMap) {
1135 this.motMap = motMap;
1136 T = motMap.length;
1137 res = motMap[0].length;
1138 }
1139
1140
1141
1142
1143
1144
1145 public double[][] getConvMap() {
1146 return convMap;
1147 }
1148
1149
1150
1151
1152
1153
1154 public FluoMap[] getFluMaps() {
1155 return fluoMaps;
1156 }
1157
1158
1159
1160
1161
1162
1163
1164
1165 public void setConvMap(double[][] convMap) {
1166 this.convMap = convMap;
1167 T = convMap.length;
1168 res = convMap[0].length;
1169 }
1170
1171
1172
1173
1174
1175
1176
1177
1178 public void setParams(Qp params) {
1179 this.params = params;
1180 }
1181
1182
1183
1184
1185
1186
1187 @Override
1188 public void beforeSerialize() {
1189 }
1190
1191
1192
1193
1194
1195
1196 @Override
1197 public void afterSerialize() throws Exception {
1198 LOGGER.debug("This class can not be deserialzied without assgning OutlineHndler and Qp");
1199 }
1200 }