Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Deep Unfolding RPCA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MINDS
These Vassili PUSTOVALOV
Deep Unfolding RPCA
Commits
e766c3e3
Commit
e766c3e3
authored
2 months ago
by
vpustova
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
81156239
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SimPlatform/Simulator.py
+88
-0
88 additions, 0 deletions
SimPlatform/Simulator.py
with
88 additions
and
0 deletions
SimPlatform/Simulator.py
0 → 100644
+
88
−
0
View file @
e766c3e3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 8 15:45:43 2018
@author: Yi Zhang
"""
import
numpy
as
np
from
scipy.signal
import
convolve2d
from
SimPlatform.ZoneTissue
import
ZoneTissue
from
SimPlatform.ZoneBubbles
import
ZoneBubbles
from
SimPlatform.Parameters
import
params_default
from
scipy.special
import
gamma
"""
Parameters for ultrasonic device
"""
"""
1.pixel: size of pixel of screen. unit=mm, pixel[0] corresponds to y dimension,
pixel[1] corresponds to x dimension.
2.psf: the standard variation of the point spread function. psf[0] corresponds to
y dimension, psf[1] corresponds to x dimension.
"""
class
Simulator
:
def
__init__
(
self
,
params
=
params_default
):
#global settings
self
.
pixel
=
params
[
'
pixel
'
]
#size of pixel, unit: mm
self
.
shape
=
params
[
'
shape
'
]
self
.
ampbubbles
=
params
[
'
ampbubbles
'
]
self
.
amptissue
=
params
[
'
amptissue
'
]
self
.
sigman
=
params
[
'
ampnoise
'
]
self
.
sigman
=
self
.
sigman
/
np
.
sqrt
(
2
)
/
gamma
(
1.5
)
#bubbles settings
self
.
zTissue
=
ZoneTissue
(
params
)
self
.
zBubbles
=
ZoneBubbles
(
params
)
#psf
s1
,
s2
=
params
[
'
psf
'
]
s1
=
s1
/
self
.
pixel
[
0
]
s2
=
s2
/
self
.
pixel
[
1
]
fshape
=
[
int
(
10
*
s1
),
int
(
10
*
s2
)]
xc
,
yc
=
(
fshape
[
1
]
-
1
)
/
2
,(
fshape
[
0
]
-
1
)
/
2
xv
,
yv
=
np
.
meshgrid
(
np
.
arange
(
fshape
[
1
])
-
xc
,
np
.
arange
(
fshape
[
0
])
-
yc
)
self
.
filter
=
np
.
exp
(
-
(
xv
**
2
/
2
/
s2
**
2
+
yv
**
2
/
2
/
s1
**
2
))
self
.
filter
=
self
.
filter
.
astype
(
np
.
float64
)
def
generate
(
self
,
T
=
20
):
Tissue
=
np
.
zeros
(
self
.
shape
+
tuple
([
T
]),
dtype
=
np
.
float64
)
Bubbles
=
np
.
zeros
(
self
.
shape
+
tuple
([
T
]),
dtype
=
np
.
float64
)
noi
=
np
.
zeros
(
self
.
shape
+
tuple
([
T
]),
dtype
=
np
.
float64
)
#phi=np.random.uniform(0,2*np.pi)
#lmd=2*np.pi*15e6/34e4*self.pixel[0]
#_,yv=np.meshgrid(np.arange(self.shape[1]),np.arange(self.shape[0]))
#phase0=np.exp(1j*phi)*np.exp(1j*lmd*yv)
#phase=np.zeros(self.shape+tuple([T]),dtype=np.complex128)
for
t
in
range
(
T
):
Bubbles
[:,:,
t
]
=
np
.
real
(
self
.
zBubbles
.
image
())
Tissue
[:,:,
t
]
=
np
.
real
(
self
.
zTissue
.
image
())
noi
[:,:,
t
]
=
np
.
random
.
normal
(
0
,
self
.
sigman
,
self
.
shape
)
#+1j*np.random.normal(0,self.sigman,self.shape)
#phase[:,:,t]=phase0
self
.
zBubbles
.
refresh
()
self
.
zTissue
.
refresh
()
#control the amplitude of bubbles, tissue and noise
tmpb
=
Bubbles
[
Bubbles
!=
0
]
if
not
(
np
.
sum
(
np
.
abs
(
Bubbles
))
==
0
):
Bubbles
=
Bubbles
*
self
.
ampbubbles
/
np
.
mean
(
np
.
abs
(
tmpb
))
AMtissue
=
np
.
random
.
uniform
(
0.6
,
1
,[
1
])
Tissue
=
Tissue
*
self
.
amptissue
/
np
.
max
(
np
.
abs
(
Tissue
))
*
2
*
AMtissue
#point spread function
for
i
in
range
(
T
):
Bubbles
[:,:,
i
]
=
self
.
psf
(
Bubbles
[:,:,
i
])
Tissue
[:,:,
i
]
=
self
.
psf
(
Tissue
[:,:,
i
])
noi
[:,:,
i
]
=
self
.
psf
(
noi
[:,:,
i
])
Sum
=
Bubbles
+
Tissue
+
noi
return
Sum
,
Bubbles
,
Tissue
def
psf
(
self
,
A
):
return
convolve2d
(
A
,
self
.
filter
,
mode
=
'
same
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment