Commit 52bdd612 authored by Krzysztof Gonciarz's avatar Krzysztof Gonciarz
Browse files

Fix for filtering colocalization channels

parent 83270219
...@@ -6,14 +6,20 @@ import java.io.IOException; ...@@ -6,14 +6,20 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
import org.apache.log4j.Logger;
import ij.IJ; import ij.IJ;
import mosaic.bregman.ColocalizationAnalysis.ChannelPair; import mosaic.bregman.ColocalizationAnalysis.ChannelPair;
import mosaic.utils.Debug;
public class RScript { public class RScript {
private static final Logger logger = Logger.getLogger(RScript.class);
public static final String ScriptName = "R_analysis.R"; public static final String ScriptName = "R_analysis.R";
/* /*
...@@ -41,11 +47,12 @@ public class RScript { ...@@ -41,11 +47,12 @@ public class RScript {
* ----------------------------------------------------------------------------------------- * -----------------------------------------------------------------------------------------
*/ */
public static void makeRScript(String path, String aObjectsDataFile, String aObjectsColocFile, String aImagesColocFile, List<ChannelPair> aChannelPairs, int[] ImagesPerGroup, String[] GroupNames, String Ch1Name, String Ch2Name) { public static void makeRScript(String path, String aObjectsDataFile, String aObjectsColocFile, String aImagesColocFile, List<ChannelPair> aChannelPairs, int[] ImagesPerGroup, String[] GroupNames, String Ch1Name, String Ch2Name) {
logger.info("Generateing Rscript with path=[" + path + "] aObjectsDataFile=[" + aObjectsDataFile + "] aObjectsColocFile=[" + aObjectsColocFile + "] aImagesColocFile=[" + aImagesColocFile + "] aChannelPairs=[" + aChannelPairs + "] ImagesPerGroup=[" + Debug.getString(ImagesPerGroup) + "] GroupNames=[" + Debug.getString(GroupNames) + "] Ch1Name=[" + Ch1Name + "] Ch2Name=[" + Ch2Name + "]");
try { try {
PrintWriter Script = new PrintWriter(path + File.separator + ScriptName); PrintWriter Script = new PrintWriter(path + File.separator + ScriptName);
Script.println("#R_analysis v2.0"); Script.println("#R_analysis v2.0");
Script.println(); Script.println();
Script.println("### Input parameters ##########################################################"); Script.println("### Input parameters ##########################################################");
Script.println(); Script.println();
...@@ -74,6 +81,7 @@ public class RScript { ...@@ -74,6 +81,7 @@ public class RScript {
Script.println(); Script.println();
List<ChannelPair> filteredPairs = filterChannelPairs(aChannelPairs); List<ChannelPair> filteredPairs = filterChannelPairs(aChannelPairs);
System.out.println("HERE");
Script.println("# Channel properties"); Script.println("# Channel properties");
int numOfChannels = findNumOfChannels(filteredPairs); int numOfChannels = findNumOfChannels(filteredPairs);
...@@ -143,15 +151,18 @@ public class RScript { ...@@ -143,15 +151,18 @@ public class RScript {
return max + 1; return max + 1;
} }
/**
* Returns filtered unique pairs of channels (from (a, b), (b, a) it returns only (a, b))
* @param aChannelPairs
* @return fitered pairs
*/
static private List<ChannelPair> filterChannelPairs(List<ChannelPair> aChannelPairs) { static private List<ChannelPair> filterChannelPairs(List<ChannelPair> aChannelPairs) {
List<ChannelPair> filteredPairs = new ArrayList<ChannelPair>(); List<ChannelPair> filteredPairs = new ArrayList<ChannelPair>();
filteredPairs.addAll(aChannelPairs); for (ChannelPair ch : aChannelPairs) {
for (ChannelPair cp : filteredPairs) { if (!filteredPairs.contains(new ChannelPair(ch.ch2, ch.ch1))) filteredPairs.add(ch);
filteredPairs.remove(new ChannelPair(cp.ch2, cp.ch1));
} }
// +1 since channels are numbered from 0
return filteredPairs; return filteredPairs;
} }
} }
...@@ -266,6 +266,7 @@ public class SquasshLauncher { ...@@ -266,6 +266,7 @@ public class SquasshLauncher {
processedChannels.add(new ChannelPair(cp.ch2, cp.ch1)); processedChannels.add(new ChannelPair(cp.ch2, cp.ch1));
ImagePlus img = generateColocImage(cp); ImagePlus img = generateColocImage(cp);
// TODO: Coloc image should be handeld in Files and be expected type of FileType.Colocalization, here channels info is added temporarily // TODO: Coloc image should be handeld in Files and be expected type of FileType.Colocalization, here channels info is added temporarily
// TODO: Add visualization flag in optoions - now colloc images are always shown which might be problem in batch processing
updateImages(i, img, Files.createTitleWithExt(FileType.Colocalization, aTitle + "_ch_" + cp.ch1 + "_" + cp.ch2), true, iOutColoc); updateImages(i, img, Files.createTitleWithExt(FileType.Colocalization, aTitle + "_ch_" + cp.ch1 + "_" + cp.ch2), true, iOutColoc);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment