Skip to content

Commit

Permalink
minor changes (fixed bug of table reading)
Browse files Browse the repository at this point in the history
  • Loading branch information
BioinfoTongLI committed May 22, 2017
1 parent 8f74da7 commit 624410b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/main/java/GuiFreeRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static void runSegmentation(MaarsParameters parameters){
public static void main(String[] args) {
new ImageJ();
String configFileName = "maars_config.xml";
String dir = "/Volumes/Macintosh/curioData/MAARSdata/102/12-06-1";
String dir = "/media/tong/MAARSData/MAARSData/rad21/16-06-2";
MaarsParameters parameters = loadMaarsParameters(configFileName, dir);
parameters.setSavingPath(dir);
//executeAnalysis(fluoAnalysisDialog.getParameters());
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/edu/univ_tlse3/maars/MAARS.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
import java.util.regex.Pattern;

/**
* Main MAARS program
Expand Down Expand Up @@ -116,17 +115,17 @@ static void saveAll(SetOfCells soc, ImagePlus mergedImg, String pathToFluoDir,
}
}

private static void findAbnormalCells(String pathToSegDir,
SetOfCells soc) {
String mitoDir = pathToSegDir + "_MITOSIS";
private static void findAbnormalCells(String mitoDir,
SetOfCells soc,
HashMap map) {
if (FileUtils.exists(mitoDir)) {
PrintWriter out = null;
try {
out = new PrintWriter(mitoDir + File.separator + "abnormalCells.txt");
} catch (FileNotFoundException e) {
IOUtils.printErrorToIJLog(e);
}
HashMap map = FileUtils.readTable(mitoDir+File.separator+"mitosis_time_board.txt");

for (Object cellNb : map.keySet()) {
int cellNbInt = Integer.parseInt(String.valueOf(cellNb));
int anaBOnsetFrame = Integer.valueOf(((String[]) map.get(cellNb))[2]);
Expand All @@ -141,7 +140,7 @@ private static void findAbnormalCells(String pathToSegDir,
if (laggingTimePoint > anaBOnsetFrame && laggingTimePoint<lastAnaphaseFrame) {
out.println("Lagging :" + cellNb + "_laggingTimePoint_" + laggingTimePoint + "_anaBonset_" + anaBOnsetFrame);
IJ.log("Lagging :" + cellNb + "_laggingTimePoint_" + laggingTimePoint + "_anaBonset_" + anaBOnsetFrame);
IJ.openImage(pathToSegDir + "_MITOSIS" + File.separator + "croppedImgs"
IJ.openImage(mitoDir + File.separator + "croppedImgs"
+ File.separator + cellNb + "_GFP.tif").show();
}
}
Expand All @@ -157,18 +156,22 @@ private static void findAbnormalCells(String pathToSegDir,
}
}

static void analyzeMitosisDynamic(SetOfCells soc, MaarsParameters parameters, String pathToSegDir, Boolean showChromLagging) {
static HashMap getMitoticCellNbs(String mitoDir){
return FileUtils.readTable(mitoDir+File.separator+"mitosis_time_board.txt");
}

static void analyzeMitosisDynamic(SetOfCells soc, MaarsParameters parameters, String pathToSegDir) {
// TODO need to find a place for the metadata, maybe in images
IJ.log("Start python analysis");
String mitoDir = pathToSegDir+ "_MITOSIS";
ArrayList<String> script = PythonPipeline.getPythonScript(pathToSegDir, parameters.getDetectionChForMitosis(),
parameters.getCalibration(), parameters.getMinimumMitosisDuration(),
String.valueOf((Math.round(Double.parseDouble(parameters.getFluoParameter(MaarsParameters.TIME_INTERVAL)) / 1000))));
PythonPipeline.savePythonScript(pathToSegDir + "_MITOSIS" + File.separator, script);
PythonPipeline.savePythonScript(mitoDir + File.separator, script);
IJ.log("Script generated");
PythonPipeline.runPythonScript(pathToSegDir+ "_MITOSIS" + File.separator);
if (showChromLagging) {
MAARS.findAbnormalCells(pathToSegDir, soc);
}
PythonPipeline.runPythonScript(mitoDir + File.separator);
HashMap map = MAARS.getMitoticCellNbs(mitoDir);
MAARS.findAbnormalCells(mitoDir, soc, map);
}


Expand Down Expand Up @@ -252,14 +255,12 @@ public void run() {
// if (FileUtils.exists(savingPath + File.separator + BF + "_1" + File.separator + "ROI.zip")) {
if (true) {
String pathToFluoDir = savingPath + File.separator + FLUO + "_1";
// parameters.setSavingPath(pathToFluoDir);
// from Roi initialize a set of cell
soc_.reset();
soc_.loadCells(savingPath + File.separator + BF + "_1");
soc_.setRoiMeasurementIntoCells(ms.getRoiMeasurements());

// ----------------start acquisition and analysis --------//
// FluoAcqSetting fluoAcq = new FluoAcqSetting(parameters);
redirectLog(savingPath);
int frame = 0;
Boolean do_analysis = Boolean.parseBoolean(parameters.getFluoParameter(MaarsParameters.DO_ANALYSIS));
Expand Down Expand Up @@ -373,11 +374,10 @@ public void run() {
if (IJ.isWindows()) {
savingPath = FileUtils.convertPathToLinuxType(savingPath + File.separator + BF + "_1");
}
MAARS.analyzeMitosisDynamic(soc_, parameters, savingPath, true);
MAARS.analyzeMitosisDynamic(soc_, parameters, savingPath);
}
ReportingUtils.logMessage("it took " + (double) (System.currentTimeMillis() - startWriting) / 1000
+ " sec for writing results");
mergedImg = null;
}
// RemoteNotification.mailNotify("[email protected]");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/univ_tlse3/maars/MAARSNoAcq.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void run() {
if (IJ.isWindows()) {
pathToSegDir = FileUtils.convertPathToLinuxType(pathToSegDir);
}
MAARS.analyzeMitosisDynamic(soc_, parameters, pathToSegDir, true);
MAARS.analyzeMitosisDynamic(soc_, parameters, pathToSegDir);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/univ_tlse3/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static HashMap<String,String[]> readTable(String path){
String[] splited;
while ((str = in.readLine()) != null) {
splited = str.split("\t");
table.put(splited[0], Arrays.copyOfRange(splited, 1, splited.length-1));
table.put(splited[0], Arrays.copyOfRange(splited, 1, splited.length));
}
in.close();
} catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/maars_default_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<TIME_INTERVAL>20000.</TIME_INTERVAL>
<TIME_LIMIT>30</TIME_LIMIT>
<DO_ANALYSIS>true</DO_ANALYSIS>
<PROJECTED>true</PROJECTED>
<PROJECTED>false</PROJECTED>
</FLUO_ANALYSIS_PARAMETERS>
<GENERAL_ACQUISITION_PARAMETERS>
<CHANNEL_GROUP>Illumination</CHANNEL_GROUP>
Expand Down

0 comments on commit 624410b

Please sign in to comment.