Closed Marc-Demoustier closed 6 months ago
The simulation 2D is now implemented with the new separations between functions (still need some updates for the domain and mesh) but I am facing an issue where the diffusion coefficient is off if I use the fit function from the previous version. It looks like some of the pixel values are pretty high, maybe it is linked to this.
It can be due to multiple things: (if it has been tested and we know it's not this, the box will be checked)
After this the simulation should be good
After analyzing the values of all variables it looks like that this is not where the issue is (see the end of this comment to see all variables values). The idea was to debug both code and see where we can observe some changes. And it looks like the same, both code are doing the same things with random numbers being in the correct range.
However, we can observe some differences in term of execution time: 01:05 (old code launched in IntelliJ IDE) vs 01:47 (new code launched in IntelliJ IDE). The issue is most likely due to too many iterations happening for some reason. Need to identify this issue.
Here are the logs: Old code:
this = {Imaging_FCS@2593}
simSeed = 1
simNoParticles = 1000
simCPS = 10000
simTauBleach = 0.0
simPixelnum = 21
simExtFactor = 1.5
simNoTStep = 50000
simFrameTime = 0.001
simStepsPerFrame = 10
simD1 = 1.0E-12
simDoutDinRatio = 1.0
simD2 = 1.0E-13
simD3 = 1.0E-14
simF2 = 0.0
simF3 = 0.0
simKon = 300.0
simKoff = 700.0
simCameraOffset = 100
simCameraNoiseFactor = 3.0
simBleachRadius = 3.0E-6
simBleachFrame = 1000000
simDomainRadius = 3.0E-8
simDomainDensity = 30.0
simPin = 1.0
simPout = 0.6
simMeshworkSize = 1.0E-7
simHopProbability = 1.0
simPixelSizeRS = 2.4E-5
simMag = 100.0
simWavelength = 5.15E-7
simNA = 1.49
simSigma0 = 0.8
newSimSettings = {String[36]@3172} ["2D (free)", "Triplet off", "1", "1000", "10000", +31 more]
simTStep = 1.0E-4
simDarkF = 0.7
numOfSeeds = 18
simSeedArray = {int[18]@3403} [1, 2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145, 170, 197, 226, 257, 290]
simPixelSize = 2.4000000000000003E-7
simPSFSize = 1.3825503355704699E-7
simGridSize = 5.040000000000001E-6
simMidPos = 2.5200000000000004E-6
simSizeLL = -7.560000000000001E-6
simSizeUL = 7.560000000000001E-6
simDetectorSize = 2.5200000000000004E-6
bleachFactor = 2.0
blinkFactor = {double[2]@3434} [0.9704455335485082, 0.9323938199059483]
gridLength = 1.5120000000000003E-5
gridMidPos = 7.560000000000001E-6
numberofdomains = 6859
domains = {double[6859][]@3453}
subgridnum = 52
subgridsize = 2.964705882352942E-7
maxdomainperarea = 391
maxct = 0
domainsorted = {int[1][][]@3469}
dsortmp = {int[52][][]@3473}
dctr = {int[52][]@3477}
num1 = 1000
num2 = 0
particles = {double[1000][]@3487}
impSim = {ImagePlus@3498} "img["2D Simulation" (-2), 16-bit, 21x21x1x50000x1]"
cs = 18
rugxpos = {UniformGenerator@3540}
rugypos = {UniformGenerator@3541}
ruig = {UniformGenerator@3542}
rugbf = {UniformGenerator@3543}
rugpin = {UniformGenerator@3544}
rugpout = {UniformGenerator@3545}
rugphop = {UniformGenerator@3546}
rugblink = {UniformGenerator@3547}
rgg1 = {GaussianGenerator@3548}
rgg2 = {GaussianGenerator@3549}
rgg3 = {GaussianGenerator@3550}
rggpsf = {GaussianGenerator@3551}
rpgphoton = {PoissonGenerator@3552}
rggnoise = {GaussianGenerator@3553}
rggdom1 = {GaussianGenerator@3554}
rggdom2 = {GaussianGenerator@3555}
rggdom3 = {GaussianGenerator@3556}
rggdrad = {GaussianGenerator@3557}
n = 0
ipSim = {ShortProcessor@3614} "ip[width=21, height=21, bits=16, min=0.0, max=65535.0]"
s = 0
m = 20
dx = 1.2191758223123185E-8
dy = -1.3098260873548387E-9
index = 1
nop = 2
p = 0
cordx = -1.239981312765639E-6
cordy = 1.6351952106872658E-6
tpx = 5
tpy = 17
tmp = 97
simSettings = {String[36]@2629} [null, null, null, null, null, +31 more]
batchSim = false
nosimsettings = 36
imp = null
particle=[-1.2095871119180109E-6, 1.8302337335402536E-6, 1.0, 0.0, 1.0]
New code:
this = {Simulation2D@2631}
model = {SimulationModel@2633}
expSettingsModel = {ExpSettingsModel@2637}
binning = {Point@2772} "java.awt.Point[x=1,y=1]"
CCF = {Dimension@2773} "java.awt.Dimension[width=0,height=0]"
pixelSize = 24.0
magnification = 100.0
NA = 1.49
sigma = 0.8
emLambda = 515.0
sigma2 = 0.8
emLamdba2 = 600.0
sigmaZ = 1000000.0
sigmaZ2 = 1000000.0
paramA = 240.0
paramW = 276.51006711409394
paramW2 = 322.1476510067114
paramZ = 3.4563758389261746E8
paramZ2 = 4.0268456375838923E8
paramRx = 0.0
paramRy = 0.0
controller = {SimulationController@2763}
imageController = {ImageController@2769}
simulationView = {SimulationView@2770}
simulationModel = {SimulationModel@2633}
expSettingsModel = {ExpSettingsModel@2637}
is2D = true
isDomain = false
isMesh = false
blinkFlag = false
seed = 1
numParticles = 1000
CPS = 10000
tauBleach = 0.0
pixelNum = 21
extFactor = 1.5
numFrames = 50000
frameTime = 0.001
stepsPerFrame = 10
D1 = 1.0E-12
doutDinRatio = 1.0
D2 = 1.0E-13
D3 = 1.0E-14
F2 = 0.0
F3 = 0.0
kon = 300.0
koff = 700.0
cameraOffset = 100
cameraNoiseFactor = 3.0
bleachRadius = 3.0E-6
bleachFrame = 10000000
domainRadius = 30.0
domainDensity = 30.0
pin = 1.0
pout = 0.6
meshWorkSize = 100.0
hopProbability = 1.0
progress = 0
state = {SwingWorker$StateValue@2764} "STARTED"
future = {SwingWorker$2@2765}
propertyChangeSupport = {SwingWorker$SwingWorkerPropertyChangeSupport@2766}
doProcess = null
doNotifyProgressChange = null
doSubmit = {SwingWorker$DoSubmitAccumulativeRunnable@2767}
settingsModel = {ExpSettingsModel@2637}
random = {RandomCustom@2632}
tStep = 1.0E-4
darkF = 0.7
pixelSize = 2.4000000000000003E-7
PSFSize = 1.3825503355704699E-7
midPos = 2.5200000000000004E-6
sizeLowerLimit = -7.560000000000001E-6
sizeUpperLimit = 7.560000000000001E-6
bleachFactor = -1.0
bleachFlag = false
particleGroup1 = 1000
particleGroup2 = 0
blinkOnFactor = 0.9704455335485082
blinkOffFactor = 0.9323938199059483
domains = null
particles = {Particle2D[1000]@2638}
impSim = {ImagePlus@2639} "img["2D Simulation" (-2), 16-bit, 21x21x1x50000x1]"
width = 21
height = 21
ipSim = {ShortProcessor@2629} "ip[width=21, height=21, bits=16, min=0.0, max=65535.0]"
particle = {Particle2D@2630}
x = -1.5523004382971206E-6
y = -2.323074589977308E-6
bleached = false
on = true
domainIndex = -1
diffusionCoefficient = 1.0E-12
numPhotons = 2
i = 0
photonX = -1.4620406917571202E-6
photonY = -2.2238906310264783E-6
xPixel = 4
yPixel = 1
currentValue = 100.0
In the end, the issue was a small inattention mistake... I used a normal random generator instead of a gaussian for photon number generation
Everything in the simulation works, just need to implement the Batch button now, it shouldn't be a big challenge. However, there are still things to think about before merging this branch:
The current simulation code is hard to read and not very optimized. The previous simulation code is the baseline for all the simulations code we have in the lab.
If this code is improved we can easily imagine that every code that takes inspiration can be written faster and with a better code quality.
However, it would be even better to have only one version that is very optimized that can be imported in every language if needed.