29
29
import java .util .HashMap ;
30
30
import java .util .Map ;
31
31
import java .util .concurrent .*;
32
- import java .util .regex .Pattern ;
33
32
34
33
/**
35
34
* Main MAARS program
@@ -116,17 +115,17 @@ static void saveAll(SetOfCells soc, ImagePlus mergedImg, String pathToFluoDir,
116
115
}
117
116
}
118
117
119
- private static void findAbnormalCells (String pathToSegDir ,
120
- SetOfCells soc ) {
121
- String mitoDir = pathToSegDir + "_MITOSIS" ;
118
+ private static void findAbnormalCells (String mitoDir ,
119
+ SetOfCells soc ,
120
+ HashMap map ) {
122
121
if (FileUtils .exists (mitoDir )) {
123
122
PrintWriter out = null ;
124
123
try {
125
124
out = new PrintWriter (mitoDir + File .separator + "abnormalCells.txt" );
126
125
} catch (FileNotFoundException e ) {
127
126
IOUtils .printErrorToIJLog (e );
128
127
}
129
- HashMap map = FileUtils . readTable ( mitoDir + File . separator + "mitosis_time_board.txt" );
128
+
130
129
for (Object cellNb : map .keySet ()) {
131
130
int cellNbInt = Integer .parseInt (String .valueOf (cellNb ));
132
131
int anaBOnsetFrame = Integer .valueOf (((String []) map .get (cellNb ))[2 ]);
@@ -141,7 +140,7 @@ private static void findAbnormalCells(String pathToSegDir,
141
140
if (laggingTimePoint > anaBOnsetFrame && laggingTimePoint <lastAnaphaseFrame ) {
142
141
out .println ("Lagging :" + cellNb + "_laggingTimePoint_" + laggingTimePoint + "_anaBonset_" + anaBOnsetFrame );
143
142
IJ .log ("Lagging :" + cellNb + "_laggingTimePoint_" + laggingTimePoint + "_anaBonset_" + anaBOnsetFrame );
144
- IJ .openImage (pathToSegDir + "_MITOSIS" + File .separator + "croppedImgs"
143
+ IJ .openImage (mitoDir + File .separator + "croppedImgs"
145
144
+ File .separator + cellNb + "_GFP.tif" ).show ();
146
145
}
147
146
}
@@ -157,18 +156,22 @@ private static void findAbnormalCells(String pathToSegDir,
157
156
}
158
157
}
159
158
160
- static void analyzeMitosisDynamic (SetOfCells soc , MaarsParameters parameters , String pathToSegDir , Boolean showChromLagging ) {
159
+ static HashMap getMitoticCellNbs (String mitoDir ){
160
+ return FileUtils .readTable (mitoDir +File .separator +"mitosis_time_board.txt" );
161
+ }
162
+
163
+ static void analyzeMitosisDynamic (SetOfCells soc , MaarsParameters parameters , String pathToSegDir ) {
161
164
// TODO need to find a place for the metadata, maybe in images
162
165
IJ .log ("Start python analysis" );
166
+ String mitoDir = pathToSegDir + "_MITOSIS" ;
163
167
ArrayList <String > script = PythonPipeline .getPythonScript (pathToSegDir , parameters .getDetectionChForMitosis (),
164
168
parameters .getCalibration (), parameters .getMinimumMitosisDuration (),
165
169
String .valueOf ((Math .round (Double .parseDouble (parameters .getFluoParameter (MaarsParameters .TIME_INTERVAL )) / 1000 ))));
166
- PythonPipeline .savePythonScript (pathToSegDir + "_MITOSIS" + File .separator , script );
170
+ PythonPipeline .savePythonScript (mitoDir + File .separator , script );
167
171
IJ .log ("Script generated" );
168
- PythonPipeline .runPythonScript (pathToSegDir + "_MITOSIS" + File .separator );
169
- if (showChromLagging ) {
170
- MAARS .findAbnormalCells (pathToSegDir , soc );
171
- }
172
+ PythonPipeline .runPythonScript (mitoDir + File .separator );
173
+ HashMap map = MAARS .getMitoticCellNbs (mitoDir );
174
+ MAARS .findAbnormalCells (mitoDir , soc , map );
172
175
}
173
176
174
177
@@ -252,14 +255,12 @@ public void run() {
252
255
// if (FileUtils.exists(savingPath + File.separator + BF + "_1" + File.separator + "ROI.zip")) {
253
256
if (true ) {
254
257
String pathToFluoDir = savingPath + File .separator + FLUO + "_1" ;
255
- // parameters.setSavingPath(pathToFluoDir);
256
258
// from Roi initialize a set of cell
257
259
soc_ .reset ();
258
260
soc_ .loadCells (savingPath + File .separator + BF + "_1" );
259
261
soc_ .setRoiMeasurementIntoCells (ms .getRoiMeasurements ());
260
262
261
263
// ----------------start acquisition and analysis --------//
262
- // FluoAcqSetting fluoAcq = new FluoAcqSetting(parameters);
263
264
redirectLog (savingPath );
264
265
int frame = 0 ;
265
266
Boolean do_analysis = Boolean .parseBoolean (parameters .getFluoParameter (MaarsParameters .DO_ANALYSIS ));
@@ -373,11 +374,10 @@ public void run() {
373
374
if (IJ .isWindows ()) {
374
375
savingPath = FileUtils .convertPathToLinuxType (savingPath + File .separator + BF + "_1" );
375
376
}
376
- MAARS .analyzeMitosisDynamic (soc_ , parameters , savingPath , true );
377
+ MAARS .analyzeMitosisDynamic (soc_ , parameters , savingPath );
377
378
}
378
379
ReportingUtils .logMessage ("it took " + (double ) (System .currentTimeMillis () - startWriting ) / 1000
379
380
+ " sec for writing results" );
380
- mergedImg = null ;
381
381
}
382
382
// RemoteNotification.mailNotify("tongli.bioinfo@gmail.com");
383
383
}
0 commit comments