Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F68951630
Simulation.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 29, 15:24
Size
3 KB
Mime Type
application/octet-stream
Expires
Mon, Jul 1, 15:24 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18652256
Attached To
R2075 deconvolution
Simulation.java
View Options
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package
deconvolution.algorithm
;
import
java.util.concurrent.Callable
;
import
bilib.tools.PsRandom
;
import
signal.ComplexSignal
;
import
signal.Operations
;
import
signal.RealSignal
;
import
signal.SignalCollector
;
public
class
Simulation
extends
AbstractAlgorithm
implements
Callable
<
RealSignal
>
{
private
static
PsRandom
rand
=
new
PsRandom
(
1234
);
private
double
mean
=
0.0
;
private
double
stdev
=
10.0
;
private
double
poisson
=
0.0
;
public
Simulation
(
double
mean
,
double
stdev
,
double
poisson
)
{
super
();
this
.
mean
=
mean
;
this
.
stdev
=
stdev
;
this
.
poisson
=
poisson
;
}
@Override
public
RealSignal
call
()
{
ComplexSignal
Y
=
fft
.
transform
(
y
);
ComplexSignal
H
=
fft
.
transform
(
h
);
ComplexSignal
X
=
Operations
.
multiply
(
H
,
Y
);
SignalCollector
.
free
(
Y
);
SignalCollector
.
free
(
H
);
RealSignal
x
=
fft
.
inverse
(
X
);
SignalCollector
.
free
(
X
);
gaussian
(
x
,
mean
,
stdev
);
poisson
(
x
,
poisson
);
return
x
;
}
public
void
gaussian
(
RealSignal
x
,
double
mean
,
double
sd
)
{
for
(
int
k
=
0
;
k
<
x
.
nz
;
k
++)
{
float
[]
slice
=
x
.
getXY
(
k
);
for
(
int
j
=
0
;
j
<
x
.
ny
*
x
.
nx
;
j
++)
slice
[
j
]
+=
(
float
)
rand
.
nextGaussian
(
mean
,
sd
);
}
}
public
void
poisson
(
RealSignal
x
,
double
factor
)
{
if
(
factor
<
Operations
.
epsilon
)
return
;
double
f
=
1.0
/(
factor
);
for
(
int
k
=
0
;
k
<
x
.
nz
;
k
++)
{
float
[]
slice
=
x
.
getXY
(
k
);
for
(
int
j
=
0
;
j
<
x
.
ny
*
x
.
nx
;
j
++)
if
(
slice
[
j
]
>
Operations
.
epsilon
)
{
slice
[
j
]
=
(
float
)(
rand
.
nextPoissonian
(
f
*(
slice
[
j
]))
*
factor
);
}
}
}
@Override
public
String
getName
()
{
return
"Simulation with noise [SIM]"
;
}
@Override
public
int
getComplexityNumberofFFT
()
{
return
3
;
}
@Override
public
double
getMemoryFootprintRatio
()
{
return
8.0
;
}
@Override
public
boolean
isRegularized
()
{
return
false
;
}
@Override
public
boolean
isStepControllable
()
{
return
false
;
}
@Override
public
boolean
isIterative
()
{
return
false
;
}
@Override
public
boolean
isWaveletsBased
()
{
return
false
;
}
@Override
public
void
setParameters
(
double
[]
params
)
{
if
(
params
==
null
)
return
;
if
(
params
.
length
>
0
)
mean
=
params
[
0
];
if
(
params
.
length
>
1
)
stdev
=
params
[
1
];
if
(
params
.
length
>
2
)
poisson
=
params
[
2
];
}
@Override
public
double
[]
getDefaultParameters
()
{
return
new
double
[]
{
0
,
1
,
0
};
}
@Override
public
double
[]
getParameters
()
{
return
new
double
[]
{
mean
,
stdev
,
poisson
};
}
@Override
public
double
getRegularizationFactor
()
{
return
0.0
;
}
@Override
public
double
getStepFactor
()
{
return
0
;
}
}
Event Timeline
Log In to Comment