Skip to content

Commit

Permalink
Improve output (#2)
Browse files Browse the repository at this point in the history
* Added Moments (EigenValues)
* Added Date to Output File name
  • Loading branch information
ppouchin authored Jul 19, 2023
1 parent 7518bfa commit bc77636
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/main/java/gred/nucleus/core/ComputeNucleiParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public void addConfigParameters(String pathToConfig) {
private String getColNameResult() {
return "NucleusFileName\t" +
"Volume\t" +
"Moment 1\t" +
"Moment 2\t" +
"Moment 3 \t" +
"Flatness\t" +
"Elongation\t" +
"Esr\t" +
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gred/nucleus/core/Measure3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,9 @@ public String nucleusParameter3D() {
results = this.rawImage.getTitle() + "\t"
// + computeVolumeObject2(255) + "\t"
+ computeVolumeObjectML() + "\t"
+ computeEigenValue3D(255)[0] + "\t"
+ computeEigenValue3D(255)[1] + "\t"
+ computeEigenValue3D(255)[2] + "\t"
+ computeFlatnessAndElongation(255)[0] + "\t"
+ computeFlatnessAndElongation(255)[1] + "\t"
+ equivalentSphericalRadius(volume) + "\t"
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/gred/nucleus/core/NucleusChromocentersAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,24 @@ public static void computeParameters(String rhfChoice,
String text = imagePlusSegmented.getTitle() + " " + volume + " "
+ measure3D.equivalentSphericalRadius(volume) + " "
+ surfaceArea + " "
+ measure3D.computeEigenValue3D(255)[0] + "\t"
+ measure3D.computeEigenValue3D(255)[1] + "\t"
+ measure3D.computeEigenValue3D(255)[2] + "\t"
+ measure3D.computeFlatnessAndElongation(255)[0] + " "
+ measure3D.computeFlatnessAndElongation(255)[1] + " "
+ measure3D.computeSphericity(volume, surfaceArea);
if (rhfChoice.equals("Volume and intensity")) {
LOGGER.info(
"ImageTitle Volume ESR SurfaceArea Flatness Elongation Sphericity IntensityRHF VolumeRHF NbCc VCcMean VCcTotal DistanceBorderToBorderMean DistanceBarycenterToBorderMean VoxelVolume");
"ImageTitle Volume ESR SurfaceArea Moment 1 Moment 2 Moment 3 Flatness Elongation Sphericity IntensityRHF VolumeRHF NbCc VCcMean VCcTotal DistanceBorderToBorderMean DistanceBarycenterToBorderMean VoxelVolume");
text += " " + measure3D.computeIntensityRHF(imagePlusInput, imagePlusSegmented, imagePlusChromocenter) + " "
+ measure3D.computeVolumeRHF(imagePlusSegmented, imagePlusChromocenter) + " ";
} else if (rhfChoice.equals("Volume")) {
LOGGER.info(
"ImageTitle Volume ESR SurfaceArea Flatness Elongation Sphericity VolumeRHF NbCc VCcMean VCcTotal DistanceBorderToBorderMean DistanceBarycenterToBorderMean VoxelVolume");
"ImageTitle Volume ESR SurfaceArea Moment 1 Moment 2 Moment 3 Flatness Elongation Sphericity VolumeRHF NbCc VCcMean VCcTotal DistanceBorderToBorderMean DistanceBarycenterToBorderMean VoxelVolume");
text += " " + measure3D.computeVolumeRHF(imagePlusSegmented, imagePlusChromocenter) + " ";
} else {
LOGGER.info(
"ImageTitle Volume ESR SurfaceArea Flatness Elongation Sphericity IntensityRHF NbCc VCcMean VCcTotal DistanceBorderToBorderMean DistanceBarycenterToBorderMean VoxelVolume");
"ImageTitle Volume ESR SurfaceArea Moment 1 Moment 2 Moment 3 Flatness Elongation Sphericity IntensityRHF NbCc VCcMean VCcTotal DistanceBorderToBorderMean DistanceBarycenterToBorderMean VoxelVolume");
text += " " +
measure3D.computeIntensityRHF(imagePlusInput, imagePlusSegmented, imagePlusChromocenter) +
" ";
Expand Down Expand Up @@ -132,19 +135,22 @@ public static void computeParameters(String pathResultsFile,
if (!exist) {
if (rhfChoice.equals("Volume and intensity")) {
text =
"ImageTitle\tVolume\tESR\tSurfaceArea\tFlatness\tElongation\tSphericity\tIntensityRHF\tVolumeRHF\tNbCc\tVCcMean\tVCcTotal\tDistanceBorderToBorderMean\tDistanceBarycenterToBorderMean\tVoxelVolume\n";
"ImageTitle\tVolume\tESR\tSurfaceArea\tMoment 1\tMoment 2 \tMoment 3 \tFlatness\tElongation\tSphericity\tIntensityRHF\tVolumeRHF\tNbCc\tVCcMean\tVCcTotal\tDistanceBorderToBorderMean\tDistanceBarycenterToBorderMean\tVoxelVolume\n";
} else if (rhfChoice.equals("Volume")) {
text =
"ImageTitle\tVolume\tESR\tSurfaceArea\tFlatness\tElongation\tSphericity\tVolumeRHF\tNbCc\tVCcMean\tVCcTotal\tDistanceBorderToBorderMean\tDistanceBarycenterToBorderMean\tVoxelVolume\n";
"ImageTitle\tVolume\tESR\tSurfaceArea\tMoment 1\tMoment 2 \tMoment 3 \tFlatness\tElongation\tSphericity\tVolumeRHF\tNbCc\tVCcMean\tVCcTotal\tDistanceBorderToBorderMean\tDistanceBarycenterToBorderMean\tVoxelVolume\n";
} else {
text =
"ImageTitle\tVolume\tESR\tSurfaceArea\tFlatness\tElongation\tSphericity\tIntensityRHF\tNbCc\tVCcMean\tVCcTotal\tDistanceBorderToBorderMean\tDistanceBarycenterToBorderMean\tVoxelVolume\n";
"ImageTitle\tVolume\tESR\tSurfaceArea\tMoment 1 \tMoment 2 \tMoment 3 \tFlatness\tElongation\tSphericity\tIntensityRHF\tNbCc\tVCcMean\tVCcTotal\tDistanceBorderToBorderMean\tDistanceBarycenterToBorderMean\tVoxelVolume\n";
}
}
text += imagePlusSegmented.getTitle() + "\t"
+ volume + "\t"
+ measure3D.equivalentSphericalRadius(volume) + "\t"
+ surfaceArea + "\t"
+ measure3D.computeEigenValue3D(255)[0] + "\t"
+ measure3D.computeEigenValue3D(255)[1] + "\t"
+ measure3D.computeEigenValue3D(255)[2] + "\t"
+ measure3D.computeFlatnessAndElongation(255)[0] + "\t"
+ measure3D.computeFlatnessAndElongation(255)[1] + "\t"
+ measure3D.computeSphericity(volume, surfaceArea) + "\t";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public void run() throws IOException, FormatException {
public String getResultsColumnNames() {
return "NucleusFileName\t" +
"Volume\t" +
"Moment 1\t" +
"Moment 2\t" +
"Moment 3 \t" +
"Flatness\t" +
"Elongation\t" +
"Sphericity\t" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public static void main(String[] args) throws Exception {
public static String getResultsColumnNames() {
return "NucleusFileName\t" +
"Volume\t" +
"Moment 1\t" +
"Moment 2\t" +
"Moment 3 \t" +
"Flatness\t" +
"Elongation\t" +
"Esr\t" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public static ImagePlus generateSegmentedImage(ImagePlus imagePlusInput,
public static String getResultsColumnNames() {
return "NucleusFileName\t" +
"Volume\t" +
"Moment 1\t" +
"Moment 2\t" +
"Moment 3 \t" +
"Flatness\t" +
"Elongation\t" +
"Esr\t" +
Expand Down
26 changes: 18 additions & 8 deletions src/main/java/gred/nucleus/segmentation/SegmentationCalling.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import fr.igred.omero.Client;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.repository.DatasetWrapper;
import fr.igred.omero.repository.ImageWrapper;
import fr.igred.omero.roi.ROIWrapper;
import fr.igred.omero.repository.DatasetWrapper;
import gred.nucleus.core.ConvexHullSegmentation;
import gred.nucleus.core.NucleusSegmentation;
import gred.nucleus.files.Directory;
import gred.nucleus.files.FilesNames;
import gred.nucleus.files.OutputTextFile;
import gred.nucleus.core.ConvexHullSegmentation;
import gred.nucleus.core.NucleusSegmentation;
import gred.nucleus.nucleuscaracterisations.NucleusAnalysis;
import ij.ImagePlus;
import ij.io.FileSaver;
Expand All @@ -29,6 +29,7 @@
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutionException;

Expand Down Expand Up @@ -280,20 +281,24 @@ public String runOneImage(String filePath) throws IOException, FormatException {
LOGGER.info("End: {}", timeStampStart);
return log;
}


public void saveCropGeneralInfo() {
Date date = new Date() ;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss") ;
LOGGER.info("Saving crop general info.");
OutputTextFile resultFileOutputOTSU = new OutputTextFile(this.segmentationParameters.getOutputFolder()
+ "OTSU"
+ File.separator
+ "result_Segmentation_Analyse_OTSU.csv");
+ dateFormat.format(date)
+ "-result_Segmentation_Analyse_OTSU.csv");
resultFileOutputOTSU.saveTextFile(this.outputCropGeneralInfoOTSU, true);
if (this.segmentationParameters.getConvexHullDetection()) {
OutputTextFile resultFileOutputConvexHull = new OutputTextFile(this.segmentationParameters.getOutputFolder()
+ NucleusSegmentation.CONVEX_HULL_ALGORITHM
+ File.separator
+ "result_Segmentation_Analyse_" +
+ dateFormat.format(date)
+ "-result_Segmentation_Analyse_" +
NucleusSegmentation.CONVEX_HULL_ALGORITHM +
".csv");
resultFileOutputConvexHull.saveTextFile(this.outputCropGeneralInfoConvexHull, true);
Expand Down Expand Up @@ -342,10 +347,12 @@ public String runSeveralImagesOMERO(List<ImageWrapper> images, Long output, Clie

public void saveCropGeneralInfoOmero(Client client, Long output)
throws ServiceException, AccessException, ExecutionException, InterruptedException {
Date date = new Date() ;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss") ;
LOGGER.info("Saving OTSU results.");
DatasetWrapper dataset = client.getProject(output).getDatasets("OTSU").get(0);

String path = "." + File.separator + "result_Segmentation_Analyse.csv";
String path = "." + File.separator + dateFormat.format(date) + "-result_Segmentation_Analyse.csv";
try {
path = new File(path).getCanonicalPath();
} catch (IOException e) {
Expand Down Expand Up @@ -504,6 +511,9 @@ private void preProcessImage(ImagePlus img) {
public String getResultsColumnNames() {
return "NucleusFileName\t" +
"Volume\t" +
"Moment 1 \t" +
"Moment 2 \t" +
"Moment 3 \t" +
"Flatness\t" +
"Elongation\t" +
"Esr\t" +
Expand Down

0 comments on commit bc77636

Please sign in to comment.