Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no StatsInfo option to importer #3580

Merged
merged 8 commits into from
Mar 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/blitz/resources/omero/Repositories.ice
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ module omero {
**/
omero::RBool doThumbnails;

/**
* Whether we are to disable StatsInfo population.
**/
omero::RBool noStatsInfo;

/**
* User choice of checksum algorithm for verifying upload.
**/
Expand Down
28 changes: 1 addition & 27 deletions components/blitz/src/ome/formats/importer/ImportCandidates.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ protected ImportContainer singleFile(File file, ImportConfig config)
file, null, null,
readerClassName, usedFiles, isSPW);
ic.setDoThumbnails(config.doThumbnails.get());
ic.setNoStatsInfo(config.noStatsInfo.get());
String configImageName = config.userSpecifiedName.get();
if (configImageName == null)
{
Expand Down Expand Up @@ -482,33 +483,6 @@ private List<String> getImageNames() {
return toReturn;
}

/**
* Creates a Pixels object populated with the dimensions for each image
* that Bio-Formats has detected.
* @return A list of Pixels objects, in the order of <i>series</i>
* populated with dimensions X, Y, Z, C and T.
*/
private List<Pixels> getPixelsWithDimensions()
{
List<Pixels> toReturn = new ArrayList<Pixels>();
for (int i = 0; i < reader.getSeriesCount(); i++)
{
reader.setSeries(i);
Pixels pixels = new PixelsI();
PixelsType pixelsType = new PixelsTypeI();
pixelsType.setValue(rstring(
FormatTools.getPixelTypeString(reader.getPixelType())));
pixels.setSizeX(rint(reader.getSizeX()));
pixels.setSizeY(rint(reader.getSizeY()));
pixels.setSizeZ(rint(reader.getSizeZ()));
pixels.setSizeC(rint(reader.getSizeC()));
pixels.setSizeT(rint(reader.getSizeT()));
pixels.setPixelsType(pixelsType);
toReturn.add(pixels);
}
return toReturn;
}

/**
* This method uses the {@link FileInfo#usedToInitialize} flag to re-order
* used files. All files which can be used to initialize a fileset are
Expand Down
2 changes: 2 additions & 0 deletions components/blitz/src/ome/formats/importer/ImportConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public class ImportConfig {
public final StrValue sessionKey;
public final LongValue group;
public final BoolValue doThumbnails;
public final BoolValue noStatsInfo;
public final StrValue email;
public final StrValue userSpecifiedName;
public final StrValue userSpecifiedDescription;
Expand Down Expand Up @@ -244,6 +245,7 @@ public synchronized void load() {
sessionKey = new StrValue("session", this);
group = new LongValue("group", this, null);
doThumbnails = new BoolValue("doThumbnails", this, true);
noStatsInfo = new BoolValue("noStatsInfo", this, false);
email = new StrValue("email", this);
qaBaseURL = new StrValue("qaBaseURL", this, DEFAULT_QABASEURL);
userSpecifiedName = new StrValue("userSpecifiedName", this);
Expand Down
26 changes: 25 additions & 1 deletion components/blitz/src/ome/formats/importer/ImportContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class ImportContainer
private String userSpecifiedName;
private String userSpecifiedDescription;
private boolean doThumbnails = true;
private boolean noStatsInfo = false;
private List<Annotation> customAnnotationList;
private IObject target;
private String checksumAlgorithm;
Expand Down Expand Up @@ -86,7 +87,7 @@ public ImportContainer(ImportConfig config,
/**
* Retrieves whether or not we are performing thumbnail creation upon
* import completion.
* return <code>true</code> if we are to perform thumbnail creation and
* @return <code>true</code> if we are to perform thumbnail creation and
* <code>false</code> otherwise.
* @since OMERO Beta 4.3.0.
*/
Expand All @@ -107,6 +108,28 @@ public void setDoThumbnails(boolean v)
doThumbnails = v;
}

/**
* Retrieves whether or not we disabling <codeStatsInfo</code> population.
* @returns <code>true</code> if we are to disable <code>StatsInfo</code>
* population. <code>false</code> otherwise.
* @since OMERO 5.1.
*/
public boolean getNoStatsInfo()
{
return noStatsInfo;
}

/**
* Sets whether or not we disabling <codeStatsInfo</code> population.
* @param v <code>true</code> if we are to disable <code>StatsInfo</code>
* population. <code>false</code> otherwise.
* @since OMERO 5.1.
*/
public void setNoStatsInfo(boolean v)
{
noStatsInfo = v;
}

/**
* Retrieves the current custom image/plate name string.
* @return As above. <code>null</code> if it has not been set.
Expand Down Expand Up @@ -298,6 +321,7 @@ public void fillData(ImportConfig config, ImportSettings settings, Fileset fs,
// TODO: These should possible be a separate option like
// ImportUserSettings rather than misusing ImportContainer.
settings.doThumbnails = rbool(getDoThumbnails());
settings.noStatsInfo = rbool(getNoStatsInfo());
settings.userSpecifiedTarget = getTarget();
settings.userSpecifiedName = getUserSpecifiedName() == null ? null
: rstring(getUserSpecifiedName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,14 @@ public static void main(String[] args) throws Exception {
LongOpt qaBaseURL = new LongOpt(
"qa_baseurl", LongOpt.REQUIRED_ARGUMENT, null, 21);

LongOpt noStatsInfo =
new LongOpt("no_stats_info", LongOpt.NO_ARGUMENT, null, 22);

// DEPRECATED OPTIONS
LongOpt plateName = new LongOpt(
"plate_name", LongOpt.REQUIRED_ARGUMENT, null, 22);
"plate_name", LongOpt.REQUIRED_ARGUMENT, null, 90);
LongOpt plateDescription = new LongOpt(
"plate_description", LongOpt.REQUIRED_ARGUMENT, null, 23);
"plate_description", LongOpt.REQUIRED_ARGUMENT, null, 91);

Getopt g = new Getopt(APP_NAME, args, "cfl:s:u:w:d:r:k:x:n:p:h",
new LongOpt[] { debug, report, upload, logs, email,
Expand All @@ -528,7 +531,7 @@ public static void main(String[] args) throws Exception {
annotationLink, transferOpt, advancedHelp,
checksumAlgorithm, minutesWait,
closeCompleted, waitCompleted, autoClose,
exclude,
exclude, noStatsInfo,
qaBaseURL, plateName, plateDescription});
int a;

Expand Down Expand Up @@ -653,17 +656,21 @@ public static void main(String[] args) throws Exception {
config.qaBaseURL.set(g.getOptarg());
break;
}
case 22: {
config.noStatsInfo.set(true);
break;
}
// ADVANCED END ---------------------------------------------------
// DEPRECATED OPTIONS
case 22: {
case 90: {
if (userSpecifiedNameAlreadySet) {
usage();
}
config.userSpecifiedName.set(g.getOptarg());
userSpecifiedNameAlreadySet = true;
break;
}
case 23: {
case 91: {
if (userSpecifiedDescriptionAlreadySet) {
usage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
*/
public class ManagedImportRequestI extends ImportRequest implements IRequest {

private static final long serialVersionUID = -303948503984L;
private static final long serialVersionUID = -303948503985L;

private static Logger log = LoggerFactory.getLogger(ManagedImportRequestI.class);

Expand Down Expand Up @@ -134,6 +134,8 @@ public class ManagedImportRequestI extends ImportRequest implements IRequest {

private boolean doThumbnails = true;

private boolean noStatsInfo = false;

private String fileName = null;

private String shortName = null;
Expand Down Expand Up @@ -215,6 +217,8 @@ public void init(Helper helper) {
annotationList = settings.userSpecifiedAnnotationList;
doThumbnails = settings.doThumbnails == null ? true :
settings.doThumbnails.getValue();
noStatsInfo = settings.noStatsInfo == null ? false :
settings.noStatsInfo.getValue();

detectAutoClose();

Expand Down Expand Up @@ -570,7 +574,7 @@ public Object pixelData(PixelDataJob pdj) throws Throwable {

store.updatePixels(pixList);

if (!reader.isMinMaxSet())
if (!reader.isMinMaxSet() && !noStatsInfo)
{
store.populateMinMax();
}
Expand Down
1 change: 1 addition & 0 deletions components/common/test/ome/testing/ObjectFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static Pixels createPixelGraphWithChannels(Pixels example, int channelCou
pi.setValue("RGB");

pt.setValue("int8");
pt.setBitSize(8);

dO.setValue("XYZTC");

Expand Down
5 changes: 4 additions & 1 deletion components/rendering/src/omeis/providers/re/HSBStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,14 @@ private List<QuantumStrategy> getStrategies() {
if (overlays != null)
{
QuantumDef def = new QuantumDef(); // Just to fulfill interface
Pixels pixels = new Pixels();
PixelsType bitType = new PixelsType();
bitType.setValue(PlaneFactory.BIT);
bitType.setBitSize(1);
pixels.setPixelsType(bitType);
for (int i = 0; i < overlays.size(); i++)
{
strats.add(new BinaryMaskQuantizer(def, bitType));
strats.add(new BinaryMaskQuantizer(def, pixels));
}
}
return strats;
Expand Down
15 changes: 5 additions & 10 deletions components/rendering/src/omeis/providers/re/QuantumManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,12 @@ class QuantumManager {
*
* @param qd
* The quantum definition which dictates what strategy to use.
* @param type
* The pixels' type.
* @param waves
* Rendering settings associated to each wavelength (channel).
*/
void initStrategies(QuantumDef qd, PixelsType type,
List<ChannelBinding> waves) {
void initStrategies(QuantumDef qd, List<ChannelBinding> waves) {
ChannelBinding[] cb = waves.toArray(new ChannelBinding[waves.size()]);
initStrategies(qd, type, cb);
initStrategies(qd, cb);
}

/**
Expand All @@ -87,12 +84,10 @@ void initStrategies(QuantumDef qd, PixelsType type,
*
* @param qd
* The quantum definition which dictates what strategy to use.
* @param type
* The pixels' type.
* @param waves
* Rendering settings associated to each wavelength (channel).
*/
void initStrategies(QuantumDef qd, PixelsType type, ChannelBinding[] waves) {
void initStrategies(QuantumDef qd, ChannelBinding[] waves) {
QuantumStrategy stg;
double gMin, gMax;
int w = 0;
Expand All @@ -101,10 +96,10 @@ void initStrategies(QuantumDef qd, PixelsType type, ChannelBinding[] waves) {
double[] minmax;
for (Iterator<Channel> i = metadata.iterateChannels(); i.hasNext();) {
channel = i.next();
stg = factory.getStrategy(qd, type);
stg = factory.getStrategy(qd, metadata);
StatsInfo statsInfo = channel.getStatsInfo();
if (statsInfo == null) {
minmax = sf.initPixelsRange(type);
minmax = sf.initPixelsRange(metadata);
gMin = minmax[0];
gMax = minmax[1];
} else {
Expand Down
4 changes: 2 additions & 2 deletions components/rendering/src/omeis/providers/re/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public Renderer(QuantumFactory quantumFactory,
QuantumDef qd = rndDef.getQuantization();
quantumManager = new QuantumManager(metadata, quantumFactory);
ChannelBinding[] cBindings = getChannelBindings();
quantumManager.initStrategies(qd, metadata.getPixelsType(), cBindings);
quantumManager.initStrategies(qd, cBindings);

// Create and configure the codomain chain.
codomainChain = new CodomainChain(qd.getCdStart().intValue(), qd
Expand Down Expand Up @@ -429,7 +429,7 @@ public Map<byte[], Integer> getOverlays() {
public void updateQuantumManager() {
QuantumDef qd = rndDef.getQuantization();
ChannelBinding[] cb = getChannelBindings();
quantumManager.initStrategies(qd, metadata.getPixelsType(), cb);
quantumManager.initStrategies(qd, cb);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,22 +220,41 @@ private double accumulateCloseToMax(int[] totals, BasicSegment[] segments,
return s;
}


/**
* Determines the minimum and maximum corresponding to the passed
* pixels type.
* pixels.
*
* @param type The pixels type to handle.
* @param metadata The pixels to handle.
*/
public double[] initPixelsRange(PixelsType type)
public double[] initPixelsRange(Pixels metadata)
{
PixelsType type = metadata.getPixelsType();
double[] minmax = new double[] {0, 1};
if (type == null) return minmax;
String typeAsString = type.getValue();
long[] values = FormatTools.defaultMinMax(
FormatTools.pixelTypeFromString(typeAsString));
minmax[0] = values[0];
minmax[1] = values[1];
int bfPixelsType = FormatTools.pixelTypeFromString(typeAsString);

// Handle floating point types first
if (FormatTools.isFloatingPoint(bfPixelsType)) {
long[] values = FormatTools.defaultMinMax(bfPixelsType);
minmax[0] = values[0];
minmax[1] = values[1];
return minmax;
}

// Use significant bits if they are available for integral pixel types.
Integer significantBits = metadata.getSignificantBits();
if (significantBits == null) {
significantBits = type.getBitSize();
}
significantBits = Math.min(significantBits, type.getBitSize());
if (FormatTools.isSigned(bfPixelsType)) {
minmax[0] = -Math.pow(2, significantBits - 1);
minmax[1] = Math.pow(2, significantBits - 1) - 1;
} else {
minmax[0] = 0;
minmax[1] = Math.pow(2, significantBits) - 1;
}
return minmax;
}

Expand All @@ -258,7 +277,7 @@ public void computeLocationStats(final Pixels metadata,
inputStart = 0;
inputEnd = 1;
if (stats == null) {
double[] values = initPixelsRange(metadata.getPixelsType());
double[] values = initPixelsRange(metadata);
inputStart = values[0];
inputEnd = values[1];
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// Third-party libraries

// Application-internal dependencies
import ome.model.core.Pixels;
import ome.model.display.QuantumDef;
import ome.model.enums.PixelsType;
import omeis.providers.re.data.PlaneFactory;
Expand All @@ -27,12 +28,13 @@ public class BinaryMaskQuantizer extends QuantumStrategy
* Creates a new strategy.
*
* @param qd Quantum definition object, contained mapping data.
* @param type The pixel type. Must be of type <code>bit</code>.
* @param type The pixels. Must be of type <code>bit</code>.
*/
public BinaryMaskQuantizer(QuantumDef qd, PixelsType type)
public BinaryMaskQuantizer(QuantumDef qd, Pixels pixels)
{
super(qd, type);
if (!PlaneFactory.BIT.equals(type))
super(qd, pixels);
PixelsType type = pixels.getPixelsType();
if (!PlaneFactory.BIT.equals(type.getValue()))
{
throw new IllegalArgumentException(
"The type " + type.getValue() + " != 'bit'.");
Expand Down