-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsimpleAnalysis.py
More file actions
executable file
·114 lines (83 loc) · 2.13 KB
/
simpleAnalysis.py
File metadata and controls
executable file
·114 lines (83 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""Example script that outlines how to analyze a FRAP dataset with PyFRAP
using scripts.
(1) Creates embryo object.
(2) Analyzes image data.
(3) Runs simulation.
(4) Fits data.
(5) Shows result output.
(6) If an output filename is given, will save embryo file to it.
Run as follows:
python simpleAnalysis.py path/to/recovery/data/ outputFilePath
"""
# Import modules
import os
import sys
import time
from pyfrp.subclasses import pyfrp_embryo
from pyfrp.modules import pyfrp_gmsh_geometry
# Data parameters
frameinterval=1.
dataResMu=512.
sliceRadius=300.
sidelength=140.
sliceDepth=15.
sliceWidth=5
center=[256,256]
rimFactor=0.8
# Simulation parameters
D=50
steps=1001
tEnd=1500
# Start timer
starTime=time.time()
# Create embryo
emb=pyfrp_embryo.embryo("Demo")
# Define where data is
emb.setDataFolder(sys.argv[1])
# Set data parameters
emb.setDataResMu(dataResMu)
emb.setFrameInterval(frameinterval)
# Set experimental details
emb.setDataResMu(dataResMu)
emb.setSideLengthBleachedMu(sidelength)
emb.setSliceDepthMu(sliceDepth)
# Create a .geo file of a 2 dimensional domain
d=pyfrp_gmsh_geometry.domain()
d.addCircleByParameters(center,sliceRadius,-sliceDepth,10,genLoop=True,genSurface=True)
d.writeToFile("demo.geo")
# Define geometry
emb.setGeometry2Custom(center,fnGeo='demo.geo',dim=2)
#Create default ROIs
emb.genDefaultROIs(emb.geometry.getCenter(),sliceRadius,rimFactor=rimFactor)
# Create analysis
emb.newAnalysis()
# Create Simulation
sim=emb.newSimulation()
# Generate mesh
sim.mesh.genMesh(debug=True)
# Simulation settings
emb.simulation.setD(D)
emb.simulation.setTimesteps(steps)
emb.simulation.setTEnd(tEnd)
emb.simulation.toLogTimeScale()
# Create a fit
fit=emb.newFit('Testfit')
# Fit settings
fit.addROIByName('Bleached Square')
fit.addROIByName('Slice')
fit.setEqu(True)
fit.setFitPinned(True)
fit.setOptMeth('Constrained Nelder-Mead')
# Run everything
emb.quickAnalysis()
# Show results
fit.plotFit()
fit.printResults()
stopTime=time.time()
# Print time it took
print("Analysis done in ", stopTime-starTime , " seconds.")
try:
emb.save(sys.argv[2])
except IndexError:
print("Did not save embryo, no output given.")
input()