Line that loads based on the value of a variable in Flutter - flutter

I try to explain to you as best as possible what I need. I would like to create a line with the style similar to the loading ones like this:
and to be able to decide the initial and final value (for example start at 0 and end at 100) and advance the line according to the value of an int variable.
So if for example I create a line from 0 to 100 and put the value of the variable at 50 it should be half full.

Related

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.

Matlab saving without losing previous iteration's value

i'm trying to save values of iterations in a loop. After this function, they will execute other functions before coming to the next iteration. But the problem i'm facing is, it overwrites them and bcomes 000000. Only the last iteration values are seen. How can i fix it ? Is there a way not to use the same variable and save them ? i read about append but will have to use different var name n is not really nice to do so.
function DistanceMatrix(iteration,distance_row)
load('data.mat','oridata')
load('centroids.mat','centroids')
for i = distance_row:(distance_row+3)
for j=1:300 %no.genes
total=0;
for k=1:6
total=total+((oridata(j,k)- centroids(i,k))^2);
end
DistMatrix_Val(i,j)=sqrt(total);
end
end
save('DistanceMatrix.mat','DistMatrix_Val')
DistMatrix_Val;
GroupMatrix(iteration,distance_row)
end
This is the output. I WOULD LIKE TO STORE ALL ITERATION's value and not overwrite them. Can any1 help ?
OK. Use
load('DistanceMatrix.mat','DistMatrix_Val')
or
persistent DistMatrix_Val
just before the first load command you showed to us.
I think this is what you should do:
functon DistanceMatrix = DistanceMatrix(iteration,distance_row)
Rather than saving the variable at the end of the function, you return it.
After returning it you can include the variable in a bigger variable (for example a three dimensional Nx4x300 matrix)
If neccesary you can then save it at the end.

Set a certain bit to a 1 matlab

I want to set a certain bit of my configuration header to a 1 (bit 3 of Byte 10) if its not already a 1. And then I want to save this new config header as my old one. I can set the bit ok, however I'm having difficulty replacing the old byte with my new to update my configuration header. I want my new configuration header to be ConfigHeader = [128;0;0;0;0;0;0;0;0;0;30];. I know it's probably a very simple solution!!
ConfigHeader = [128;0;0;0;0;0;0;0;0;0;26];
ByteTen = ConfigHeader(11);
if bitget(ByteTen,3) == 0
% Set bit 3 of byte 10 to 1
bitset(ByteTen,3);
% Replace old config header with new one (bit changed to 1)
ConfigHeader = ??????
end
You'll have to assign the modified value back to ConfigHeader, e.g. by adding this line:
ConfigHeader(11) = bitset(ByteTen,3);
This line:
bitset(ByteTen,3);
on it's own does nothing as long as you don't use its output.
I am not used to bit operations, but juding from your code the next logical step would be:
ConfigHeader(11) = ByteTen
Perhaps your entire code can even be reduced to:
bitset(ConfigHeader(11),3)
After all, a bit can only be zero or one so you don't need to test it if you always want to end with a one.

Debugging a for loop in matlab

I've been looking throught the documentation, but can't seem to find the bit I want.
I have a for loop and I would like to be able to view every value in the for loop.
for example here is a part of my code:
for d = 1 : nb
%for loop performs blade by blade averaging and produces a column vector
for cc = navg : length(atbmat);
atb2 = (sum(atbmat((cc-(navg-1):cc),d)))/navg;
atbvec2(:,cc) = atb2;
end
%assigns column vector 'atbvec2' to the correct column of the matrix 'atbmat2'
atbmat2(d,1:length(atbvec2)) = atbvec2;
end
I would like to view every value of atb2. I'm a python user(new to MATLAB) and would normally use a simple print statement to find this.
I'm sure there is a way to do it, but I can't quite find how.
Thankyou in advance.
you can use disp in Matlab to print to the screen but you might want to use sprintf first to format it nicely. However for debugging you're better off using a break point and then inspect the variable in the workspace browser graphically. To me, this is one of Matlab's best features.
Have a look at the "Examine Values" section of this article
The simplest way to view it everywhere is to change this line:
atb2 = (sum(atbmat((cc-(navg-1):cc),d)))/navg;
Into this, without semicolon:
atb2 = (sum(atbmat((cc-(navg-1):cc),d)))/navg
That being said, given the nature of your calculation, you could get the information you need as well by simply storing every value of abt2 and observing them afterwards. This may be done in atbmat2 already?
If you want to look at each value at the time it happens, consider setting a breakpoint or conditional breakpoint after the line where abt2 is assigned.

How to add operator signs '+,-,/,*,mod' etc to a label for making a calculator?

I have made a calculator for simple operations but I cant figure out how should I add the operator signs next to the numerals that I am entering.
I created 2 functions 1 on the number being entered
-(IBAction)buttonDigitPressed:(id)sender
and another for the operation
-(IBAction)buttonOperationPressed:(id)sender.
calculatorScreen.text = [NSString stringWithFormat:#"%.2f",result];
This is for the result to be shown on the label calculatorScreen.
The result i would like would be something like "1+2*3/4" on the calculatorScreen.
Sorry if I misunderstand your question, but what you want is to display on your calculator app the full equation that you've input thus far (e.g. 63+42-62).
Like any other calculator, you should have 2 label, one for your current input, and one to show all that you've entered.(I'm guessing you need the latter)
With the second label up, you can add in the append function into your digitpressed, enter/= function, operation function. If you want to tweak it such 16+23-32 will show up as
1) 16+23
2) 39-32
3) 39-32=7
then you'll have to add in your own specific code. otherwise the label will input as 16+23-32 = 7
You can just append the character to whatever is already on calculatorScreen. Or you can save the current input in an instance variable and display where appropriate.
This is just a guideline, since I don't know the behavior of your calculator in case of this input: 1 + 2 * 3 (simple calculator will return 9, scientific will return 7).