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
e7e10394
Commit
e7e10394
authored
2 months ago
by
vpustova
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
bdac1a65
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/Functions.py
+64
-0
64 additions, 0 deletions
SimPlatform/Functions.py
with
64 additions
and
0 deletions
SimPlatform/Functions.py
0 → 100644
+
64
−
0
View file @
e7e10394
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 15 13:26:41 2018
@author: Yi Zhang
"""
import
numpy
as
np
from
numpy.random
import
normal
,
uniform
,
rand
,
randint
,
choice
from
SimPlatform.Parameters
import
params_default
"""
Parameters for envelope of amplitude of tissue
"""
"""
1.sigrange: standard variation for two-dimensional gaussian as the amplitude envelop of tissue,
unit mm. sig=[sig1min,sig1max,sig2min,sig2max]. sig1 corresponds to y dimension,
sig2 corresponds to x dimension.
2.num: number of the max areas of tissue
"""
class
Envelope
:
def
__init__
(
self
,
params
=
params_default
):
self
.
pixel
=
params
[
'
pixel
'
]
self
.
shape
=
params
[
'
shape
'
]
def
GMenvelope
(
self
,
params
=
params_default
):
"""
generate a mixed gaussian matrix as envelope of amplitude for tissue
"""
self
.
sigrange
=
params
[
'
sigrange
'
]
self
.
num
=
params
[
'
numev
'
]
ev
=
{}
m
=
{}
sig
=
{}
loc_ev
=
{}
theta_ev
=
{}
for
i
in
range
(
self
.
num
):
sig
[
i
]
=
[
uniform
(
self
.
sigrange
[
0
],
self
.
sigrange
[
1
]),
uniform
(
self
.
sigrange
[
2
],
self
.
sigrange
[
3
])]
m
[
i
]
=
max
(
int
(
3
*
sig
[
i
][
0
]
/
self
.
pixel
[
0
]),
int
(
3
*
sig
[
i
][
1
]
/
self
.
pixel
[
1
]))
xv
=
np
.
arange
(
-
m
[
i
],
m
[
i
]
+
1
)
*
self
.
pixel
[
1
]
yv
=
np
.
arange
(
-
m
[
i
],
m
[
i
]
+
1
)
*
self
.
pixel
[
0
]
xv
,
yv
=
np
.
meshgrid
(
xv
,
yv
)
theta_ev
[
i
]
=
uniform
(
0
,
2
*
np
.
pi
)
xv1
=
xv
*
np
.
cos
(
theta_ev
[
i
])
-
yv
*
np
.
sin
(
theta_ev
[
i
])
yv1
=
xv
*
np
.
sin
(
theta_ev
[
i
])
+
yv
*
np
.
cos
(
theta_ev
[
i
])
ev
[
i
]
=
np
.
exp
(
-
xv1
**
2
/
2
/
sig
[
i
][
0
]
**
2
-
yv1
**
2
/
2
/
sig
[
i
][
1
])
loc_ev
[
i
]
=
(
randint
(
self
.
shape
[
0
]),
randint
(
self
.
shape
[
1
]))
#set location of envelope
A
=
np
.
zeros
(
self
.
shape
)
for
i
in
range
(
self
.
num
):
y1
,
y2
,
x1
,
x2
=
[
max
(
0
,
loc_ev
[
i
][
0
]
-
m
[
i
]),
min
(
self
.
shape
[
0
],
loc_ev
[
i
][
0
]
+
m
[
i
]
+
1
),
max
(
0
,
loc_ev
[
i
][
1
]
-
m
[
i
]),
min
(
self
.
shape
[
1
],
loc_ev
[
i
][
1
]
+
m
[
i
]
+
1
)]
ye1
,
ye2
,
xe1
,
xe2
=
[
y1
-
loc_ev
[
i
][
0
]
+
m
[
i
],
y2
-
loc_ev
[
i
][
0
]
+
m
[
i
],
x1
-
loc_ev
[
i
][
1
]
+
m
[
i
],
x2
-
loc_ev
[
i
][
1
]
+
m
[
i
]]
A
[
y1
:
y2
,
x1
:
x2
]
+=
ev
[
i
][
ye1
:
ye2
,
xe1
:
xe2
]
return
A
\ 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