Skip to content

Commit 6e856da

Browse files
committedMar 6, 2018
added segmentation integrated image test; make rare event detection back to work
Former-commit-id: 5305246
1 parent 3e28ea6 commit 6e856da

File tree

9 files changed

+74
-209
lines changed

9 files changed

+74
-209
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ ENV/
132132
*MAARS_deps/
133133
maars_post/src/main/resources/BF_1_SegAnalysis*
134134

135+
*.html

‎maars_lib/src/main/java/maars/cellAnalysis/PythonPipeline.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import java.io.IOException;
77

88
public class PythonPipeline {
9-
public static final String ANALYSING_SCRIPT_NAME = "processMitosis.py";
10-
public static final String TRACKMATE_LOADER_NAME = "TMxml2dflib.py";
9+
public static final String ANALYSING_SCRIPT_NAME = "MaarsAnalysis.py";
1110

1211
/**
1312
* @param cmd command to execute

‎maars_lib/src/main/java/maars/main/Maars_Interface.java

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public static void waitAllTaskToFinish(CopyOnWriteArrayList<Map<String, Future>>
4242

4343
public static void copyDeps(){
4444
FileUtils.createFolder(MaarsParameters.DEPS_DIR);
45-
FileUtils.copy(MaarsParameters.DEPS_DIR, PythonPipeline.TRACKMATE_LOADER_NAME);
4645
FileUtils.copy(MaarsParameters.DEPS_DIR, PythonPipeline.ANALYSING_SCRIPT_NAME);
4746
}
4847

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# coding: utf-8
2+
# !/usr/bin/env python3
3+
4+
from maarsanalyzer.io import loader
5+
import pandas as pd
6+
from maarsanalyzer import Plotting
7+
from maarsanalyzer.MaarsAnalyzer import MaarsAnalyzer
8+
9+
if __name__ == '__main__':
10+
args = loader.set_attributes_from_cmd_line()
11+
analyser = MaarsAnalyzer(args.baseDir, args.pos, args.bf_Prefix, args.fluo_Prefix,\
12+
args.minimumPeriod, args.acq_interval, targetCh ="CFP", toCh5=True)
13+
# analyser = MaarsAnalyzer("/media/tong/screening/20_10_17",\
14+
# "dam1", "BF_1", "FLUO_1", 200, 30, targetCh ="CFP", toCh5=True)
15+
mitoFilter = analyser.getMitosisFilter()
16+
mitoCellNbs = analyser.getMitoCellNbs(mitoFilter)
17+
dict_id_spLens = analyser.getElongations(mitoCellNbs)
18+
slopeChanges = analyser.getMaxSlopes(dict_id_spLens)
19+
analyser.writeReport(mitoCellNbs, dict_id_spLens, slopeChanges)
20+
##########plotting#################
21+
Plotting.plotElong(dict_id_spLens)
22+
23+
mitoRange = pd.DataFrame(columns = ["start", "stop"])
24+
for cellId in dict_id_spLens.keys():
25+
interpolated_spLens = dict_id_spLens[cellId]
26+
mitoRange.loc[cellId] = [interpolated_spLens.index[0], interpolated_spLens.index[-1]]
27+
print(mitoRange)
28+
print(slopeChanges)
29+
# pathToXmls = [maarscsts.FLUO_SPOT + str(c) + "_" + args.channel + '.xml' for c in mitoticCellNbs]
30+
# # Track SPBs
31+
#
32+
# for ind, xmlpath in zip(mitoticCellNbs, pathToXmls):
33+
# spotXY = loader.getAllSpots(xmlpath)[[maarsConsts.POS_X, maarsConsts.POS_Y]]
34+
# spotsInRegion = spotXY.loc[region.loc[ind][0]:region.loc[ind][1]]
35+
# print(spotsInRegion)
36+
# reshaped =spLens.values.reshape(len(spLens),1)
37+
# fftmsd = msd_fft(reshaped)
38+
# fig = figure(title=p.split("/")[-1], y_range=(0.0001,10**2) , y_axis_type="log")#
39+
# fig.line(spLens.index, fftmsd, color= "blue")
40+
# row.append(fig)
41+
analyser.shutdown()
42+
print("Done")

‎maars_lib/src/main/resources/TMxml2dflib.py

-67
This file was deleted.

‎maars_lib/src/main/resources/phase_correction_with_hmm.py

-53
This file was deleted.

‎maars_lib/src/main/resources/redistribute_positions.py

-55
This file was deleted.

‎maars_post/src/main/java/maars/headless/batchFluoAnalysis/MaarsFluoAnalysis.java

+9-10
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private ImagePlus processStackedImg(String imgPath, int serie, MaarsParameters p
162162

163163
private static void findAbnormalCells(String mitoDir,
164164
DefaultSetOfCells soc,
165-
HashMap map) {
165+
HashMap slopeChanges) {
166166
assert FileUtils.exists(mitoDir);
167167
PrintWriter out = null;
168168
try {
@@ -171,10 +171,10 @@ private static void findAbnormalCells(String mitoDir,
171171
IOUtils.printErrorToIJLog(e);
172172
}
173173
assert out != null;
174-
for (Object cellNb : map.keySet()) {
174+
for (Object cellNb : slopeChanges.keySet()) {
175175
int cellNbInt = Integer.parseInt(String.valueOf(cellNb));
176-
int anaBOnsetFrame = Integer.valueOf(((String[]) map.get(cellNb))[2]);
177-
int lastAnaphaseFrame = Integer.valueOf(((String[]) map.get(cellNb))[3]);
176+
int anaBOnsetFrame = Integer.valueOf(((String[]) slopeChanges.get(cellNb))[1]);
177+
int lastAnaphaseFrame = Integer.valueOf(((String[]) slopeChanges.get(cellNb))[2]);
178178
Cell cell = soc.getCell(cellNbInt);
179179
cell.setAnaBOnsetFrame(anaBOnsetFrame);
180180
ArrayList<Integer> spotInBtwnFrames = cell.getSpotInBtwnFrames();
@@ -201,9 +201,9 @@ private static void findAbnormalCells(String mitoDir,
201201
IJ.log("lagging detection finished");
202202
}
203203

204-
// static HashMap getMitoticCellNbs(String mitoDir) {
205-
// return FileUtils.readTable(mitoDir + File.separator + "mitosis_time_board.csv");
206-
// }
204+
static HashMap getMitoticCellNbs(String mitoDir) {
205+
return FileUtils.readTable(mitoDir + File.separator + "slopeChanges.csv");
206+
}
207207

208208
public static void analyzeMitosisDynamic(DefaultSetOfCells soc, MaarsParameters parameters, double calib) {
209209
IJ.log("Start python analysis");
@@ -220,9 +220,8 @@ public static void analyzeMitosisDynamic(DefaultSetOfCells soc, MaarsParameters
220220
cmds.add(String.join(" ", mitosis_cmd));
221221
String bashPath = mitoDir + "pythonAnalysis.sh";
222222
FileUtils.writeScript(bashPath, cmds);
223-
IJ.log("Script saved");
223+
IJ.log("Script saved. If it fails, you can still run it manually afterward.");
224224
PythonPipeline.runPythonScript(mitosis_cmd, mitoDir + "mitosisDetection_log.txt");
225-
// HashMap map = getMitoticCellNbs(mitoDir);
226-
// findAbnormalCells(mitoDir, soc, map);
225+
findAbnormalCells(mitoDir, soc, getMitoticCellNbs(mitoDir));
227226
}
228227
}

‎maars_post/src/test/java/BFSegTest.java

+21-21
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,27 @@ public static Collection<Object[]> prepareFiles() throws IOException, FormatExce
140140
// }
141141

142142
//This is a dirty test of the exist of output files.
143-
@Test
144-
public void bfSegOutputTest() {
145-
String fakePosNb = "wt";
146-
Thread th = new Thread(new MaarsSegmentation(parameters_, bfimg, fakePosNb));
147-
th.start();
148-
try {
149-
th.join();
150-
} catch (InterruptedException e) {
151-
e.printStackTrace();
152-
}
153-
String outputRoot = parameters_.getSavingPath() + parameters_.getSegmentationParameter(MaarsParameters.SEG_PREFIX) + Maars_Interface.SEGANALYSIS_SUFFIX;
154-
String outputPosDir = outputRoot + File.separator + fakePosNb;
155-
Assert.assertTrue(FileUtils.exists(outputRoot));
156-
Assert.assertTrue(FileUtils.exists(outputPosDir));
157-
Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.BINARY + ".tif"));
158-
Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.INTEGRATED + ".tif"));
159-
Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.FOCUS + ".tif"));
160-
Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.ROI + ".zip"));
161-
Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.RESULTS + ".csv"));
162-
Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.SEGLOG));
163-
}
143+
// @Test
144+
// public void bfSegOutputTest() {
145+
// String fakePosNb = "wt";
146+
// Thread th = new Thread(new MaarsSegmentation(parameters_, bfimg, fakePosNb));
147+
// th.start();
148+
// try {
149+
// th.join();
150+
// } catch (InterruptedException e) {
151+
// e.printStackTrace();
152+
// }
153+
// String outputRoot = parameters_.getSavingPath() + parameters_.getSegmentationParameter(MaarsParameters.SEG_PREFIX) + Maars_Interface.SEGANALYSIS_SUFFIX;
154+
// String outputPosDir = outputRoot + File.separator + fakePosNb;
155+
// Assert.assertTrue(FileUtils.exists(outputRoot));
156+
// Assert.assertTrue(FileUtils.exists(outputPosDir));
157+
// Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.BINARY + ".tif"));
158+
// Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.INTEGRATED + ".tif"));
159+
// Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.FOCUS + ".tif"));
160+
// Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.ROI + ".zip"));
161+
// Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.RESULTS + ".csv"));
162+
// Assert.assertTrue(FileUtils.exists(outputPosDir + File.separator + SegPombe.SEGLOG));
163+
// }
164164

165165
@Test
166166
public void calculateIntegratedImgTest(){

0 commit comments

Comments
 (0)
Please sign in to comment.