How to interpret the following input to the execute method of the STAPLE filter object: Execute(const Image & image1)? - simpleitk

I am trying to use the STAPLE filter, provided by Simple ITK. I do not understand how to interpret the input in the execute method, documentation is missing. For example:
Execute(const Image &image1) OR Execute(const Image &image1, const Image &image2)
From: https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1STAPLEImageFilter.html
What does const Image mean?
What & operation will perform on Image and image1?
Thanks in advance!

Const is a C++ keyword meaning that the input parameter will not be modified in the method. The ampersand, '&', means the parameter is being passed to the method by reference. That means the entire input image isn't put on the stack, just a reference (address) to it.
These are performance/implementation issues that you don't really need to worry about. Basically you are passing one or more images to the STAPLE filter for analysis.

Related

talend thmap get value of outer loop element

I'm just starting out with thMap.
So far I have successfully mapped an X12 835 message to output structures. That works no problem.
I have also successfully acquired the LoopIndex of the current loop using the LoopIndex() function.
My challenge:
I need to get the value of an element from the enclosing loop.
In the attached image, everything in green is working.
I'm trying to get the value down the red line.
My goal is to do this assignment
gsRecord.parent_id = enclosing loop isaRecord.id
The documentation explains some things but I don't see examples putting it together.
Does anyone have any good examples, videos or suggestions?
Update from 12/9/22
Here is something I have tried. Providing this example in hopes someone recognizes a specific issue to help move me forward. Any input would be appreciated.
Per this screenshot
I am attempting to output in gsRecord.parent_id the loopIndex of the parent loop (isaRecord).
This gives me the following error
"An reference in an LoopIndex/Variable was made to an either an input
map element or an output map element that is not in the context of the
reference. Use an enclosing looping output map element here.(msg #1202)"
Given the reference to 'enclosing looping output map element here' it feels like the gsRecord is not properly defined as a child of the isaRecord.
However the definition of the gsRecord is in reference to the isaRecord as in this screenshot.
It feels like there is some combination of LoopIndex and EnclosedContext that I could use to accomplish this but I'm unable to find any in-depth documentation on the functions.
Any help would be appreciated.

API for getting language server info from extension (bracket pairs, function begin/end, ...)

I'm currently writing an extension for VSCode which needs to have some good knowledge about the currently shown code in the editor and I'm wondering if there is some API available which can give me the needed information (e.g. from the current language server) or if I have to do the heavy lifting myself by implementing all the needed code parsing etc.
What I need in detail is the following:
Given is a position in code (line + col no)
What I'd like to know about the given position:
Is pos inside a function and if so, where does the function start & end?
Is pos inside a string and if so, where does the string start & end?
The extension is going to provide some kind of "vim selection light".
You can have only half of that via VS Code APIs.
Is pos inside a function and if so, where does the function start & end?
Using the vscode.executeDocumentSymbolProvider command, you can gather all functions from a file and check if the current position is inside one of the functions.
Something like this to retrieve the functions:
const symbolsToFind = [SymbolKind.Function, SymbolKind.Method, SymbolKind.Constructor];
const docSymbols = await commands.executeCommand(
'vscode.executeDocumentSymbolProvider',
window.activeTextEditor.document.uri
) as DocumentSymbol[];
const docSymbolsFunctionsMethods = docSymbols
? docSymbols.filter(symbol => symbolsToFind.includes(symbol.kind))
: undefined;
Each Symbol provides you with a Range, which defines the start and end of the function declaration and body.
Be aware that you will probably need a recursive approach (each Symbol can contain other Symbols). A complete sample is available on my Separators extension (https://github.com/alefragnani/vscode-separators/blob/b6d515847bbaccf6395b24f9fdf82c373cb24fd7/src/symbols.ts#L51)
Is pos inside a string and if so, where does the string start & end?
Unfortunately, there is no API for that, as VS Code does not expose language tokens or the AST. So, you will have to deal with it yourself, maybe using regex.
Hope this helps

How to filter by both text and property in Chrome DevTool's network panel?

I want to filter Chrome DevTool's network panel by the method property and text in the URL. For example, if I am searching for the text chromequestion in the URL and only HTTP GET requests (ignore PUT, POST, DELETE, etc).
I am able to filter by text or by method:
I am not able to combine the filter to search by both text and method:
I read the documentation at https://developers.google.com/web/tools/chrome-devtools/network-performance/reference#filters and I am able to filter by multiple properties (.e.g, domain:*.com method:GET). However, I am unable to filter by text and property (e.g., method:GET chromequestion).
Unfortunately, it's not possible to do this currently. I played around in DevTools originally, but couldn't find a way. I later had a look into how the filtering was implemented, and can confirm there's a limitation preventing you from mixing the pre-defined filters and text filters.
Implementation details
This is a bit long but I thought it might be interesting for some to see how it's implemented. I will probably look into improving the implementation, either myself or I'll log it because it's limited.
There's a _parseFilterQuery function that parses the input field and categorises the entries into two arrays. The first is called filters, and it's the pre-defined filtering options, such as method:GET etc. The second is a text array filter, split up by spaces. The parser determines the difference fairly naively, by checking for the occurrence of :, and - at the start (for negation).
Scenario 1
You only input a pre-defined filter, or multiple filters. For each filter, the specific filter function, which looks at the different properties of the request object, is pushed to a network module filters array (this._filters). Later on, for each request, the function is called on it, and a match returns true, otherwise false. This will determine whether the request is shown. There's obviously a requirement for ALL filters to return true for the row to show.
Scenario 2
This is the interesting one, where you input both a pre-defined filter and a bit of text. This covers the Stack Overflow question. The _parseFilterQuery function looks at the text filters first, before the pre-defined ones. In Scenario 1, this was empty, so it was skipped.
We pass each text word to the _createTextFilter, and push each of the resulting filters to the network module filters array. However, the implementation of this is questionable. The only time the actual word passed in is used is to check whether its a negation filter for a bit of text. If the first character is -, it means the user doesn't want to see a request with the following word in the name. For example -icon means don't show any request with that in the name/page. If there is no negation, it simply returns the WHOLE input text as a regular expression, NOT the word passed in. In my case, it returns /method:GET icon/i.
The pre-defined filters are looked at next. In this case, method:GET is pushed.
Finally, it loops over the requests calling each filter on it. However, since the first filter is /method:GET icon/i, it makes ALL other filters redundant because it will NEVER pass. The text filters only apply to name and path, so method:GET in a text filter will be invalid.

Loading a file from a parameter in Jasper

I'm new to writing jasper reports (and SQL in general). We are trying to load an RTF or HTML file as a disclosure at the end of a report. The way we are doing this is by selecting the name of the file ("Disclosure") in part of the SQL:
SELECT
....
'Disclosure' as Disclosure
FROM
...
And then, obviously, there is a field for this:
<field name="Disclosure" class="java.lang.String"/>
At the end, in the summary section of the report, we use the loadfile utility:
<textFieldExpression class="java.lang.String"><![CDATA[JasperFileRuntimeUtility.loadFile($F{Disclosure}, $P{REPORT_PARAMETERS_MAP})]]></textFieldExpression>
If the report returns data, this works beautifully. But if the result of the original query does not return any records, then the disclosure is not included in the report (since the result of the query is nothing, obviously).
I thought we could easily work around this by providing the "Disclosure" as a Parameter, but when I change that to $P instead of $F. I get an error about invalid io file type.
I also tried creating a Variable and setting that $V to the value of the $P we are passing in, but no luck there either.
Is there a load file type of utility that will load a parameter like we are doing with the field? Any other suggestions?
Appreciate the help!!!
I have understood you question better now so I edit the answer, you are calling
JasperFileRuntimeUtility.loadFile($F{Disclosure}, $P{REPORT_PARAMETERS_MAP})
you have no clue what function is this but you know that if you pass the String "Disclosure" it works.
The class JasperFileRuntimeUtility is within your library (its not an official jasper report function), try to search your project or your libraries.
It has a static method public static String loadFile(String value, Map<?,?> map)
Calling the metod with where $F{Disclosure} = "Disclosure"
JasperFileRuntimeUtility.loadFile($F{Disclosure}, $P{REPORT_PARAMETERS_MAP})
or
JasperFileRuntimeUtility.loadFile("Disclosure", $P{REPORT_PARAMETERS_MAP})
will not make any different the result will be the same (since the method have no other idea then with what parameters you call it).
Normally also calling with a $P{Disclosure} = "Disclosure"
JasperFileRuntimeUtility.loadFile($P{Disclosure}, $P{REPORT_PARAMETERS_MAP})
would be the same, but since the the parameter map is passed the function can see this parameter and maybe do something else...
More likely however since the parameter map is passed to function, you may have scriptlet or other calls that set static fields, and when you have no result the call to loadFile is not working since these static fields have not been set.
So if it is not working passing "Disclosure" this is most certainly the case..
Have fun!

set threshold as a function of autoThreshold

I have written a macro for ImageJ/FIJI to deconvolve my confocal microscopy images and run the "3D Object Counter" plugin. The macro successfully runs all required commands and saves all required data in the specified places.
However, I have found that the 3D-OC autothreshold (as shown in the plugin dialog box) is to stringent resulting in objects being lost or divided.
To remedy this I would like to reduce the autothreshold by a predetermined function something similar to what was done here (from:How to get threshold value used by auto threshold Plugin) which resulted in this code:
setAutoThreshold();
getThreshold(lower,upper);
v=setThreshold(lower,upper*0.5);
run("3D Objects Counter", "threshold="v" slice=10 min.=400 max.=20971520 objects statistics summary");
The idea was to call the AutoThreshold values, modify them and set them to a variable. However when these lines are run the following error is returned:
Number or numeric function expected in line 3.
v=<setThreshold>(lower,upper*0.5);
And if the variable is inserted directly into the threshold key for run(3D-OC) the following msg is encountered:
Numeric value expected in run() function
Key:"threshold"
Value or variable name:"setThreshold(lower,upper*0.5"
Any suggestions or help on how to designate the 3D-OC threshold value as a variable as described would be greatly appreciated (as would any work arounds of course :) ).
Cheers
Edit: After testing Jan's response below (which works perfectly), it appears I need to call the threshold set by the 3D-OC plugin. Anyone know how to do this?
The getThreshold(lower, upper) function returns the lower and upper threshold levels in the provided variables. There is no need to assign any value to a new variable, and as you observed, setThreshold does not have any return value.
Instead, you can use the value(s) returned from getThreshold and use them as parameters in the run method (in the correct way, by string concatenation, see here):
setAutoThreshold();
getThreshold(lower, v);
run("3D Objects Counter", "threshold=" + v + " slice=10 min.=400 max.=20971520 objects statistics summary");
Alternatively, you can use &v in the second parameter to avoid string concatenation in the last line (see the documentation for the run() macro function):
run("3D Objects Counter", "threshold=&v slice=10 min.=400 max.=20971520 objects statistics summary");
You might have to use the lower instead of the upper threshold value, depending on whether you count bright or dark objects.