Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WHIM
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
Container 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
Hossein Rafipoor
WHIM
Commits
96f6ee28
Commit
96f6ee28
authored
3 years ago
by
Hossein Rafipoor
Browse files
Options
Downloads
Patches
Plain Diff
added more functions to utils
parent
9453eb20
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
requirements.txt
+4
-0
4 additions, 0 deletions
requirements.txt
setup.py
+1
-1
1 addition, 1 deletion
setup.py
whim/hbm.py
+1
-1
1 addition, 1 deletion
whim/hbm.py
whim/utils.py
+24
-0
24 additions, 0 deletions
whim/utils.py
with
30 additions
and
2 deletions
requirements.txt
+
4
−
0
View file @
96f6ee28
numpy
scipy
matplotlib
joblib
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
96f6ee28
...
...
@@ -15,7 +15,7 @@ test_requirements = ['pytest',]
setup
(
author
=
"
Hossein Rafipoor, Michiel Cottaar, Saad Jbabdi
"
,
author_email
=
'
hossein.rafipoor@ndcn.ox.ac.uk
'
,
python_requires
=
'
>=3.
6
'
,
python_requires
=
'
>=3.
7
'
,
classifiers
=
[
'
Programming Language :: Python :: 3
'
,
'
Programming Language :: Python :: 3.6
'
,
...
...
This diff is collapsed.
Click to expand it.
whim/hbm.py
+
1
−
1
View file @
96f6ee28
...
...
@@ -6,7 +6,7 @@ from dataclasses import dataclass
from
.
import
utils
@dataclass
class
hbm
()
:
class
hbm
:
forward_model
:
Callable
param_names
:
List
param_priors
:
Mapping
...
...
This diff is collapsed.
Click to expand it.
whim/utils.py
+
24
−
0
View file @
96f6ee28
...
...
@@ -155,3 +155,27 @@ def generate_acq(n_b0=10, n_dir=64, b=(1, 2, 3)):
bvecs
=
np
.
concatenate
([
bvecs
,
fibonacci_sphere
(
n_dir
)])
return
bvals
,
bvecs
def
grad
(
f
,
p
,
bounds
,
dp
=
1e-6
):
dp
=
np
.
maximum
(
1e-10
,
abs
(
p
*
dp
))
g
=
[]
for
i
in
range
(
len
(
p
)):
pi
=
np
.
zeros
(
len
(
p
))
pi
[
i
]
=
dp
[
i
]
u
=
p
+
pi
if
u
[
i
]
>
bounds
[
i
][
1
]:
u
[
i
]
=
bounds
[
i
][
1
]
l
=
p
-
pi
if
l
[
i
]
<
bounds
[
i
][
0
]:
l
[
i
]
=
bounds
[
i
][
0
]
g
.
append
((
f
(
u
)
-
f
(
l
))
/
(
u
[
i
]
-
l
[
i
]))
return
np
.
stack
(
g
,
axis
=
0
)
def
hessian
(
f
,
p
,
bounds
,
dp
=
1e-6
):
g
=
lambda
p_
:
grad
(
f
,
p_
,
bounds
,
dp
)
return
grad
(
g
,
p
,
bounds
,
dp
)
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