Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrei-Claudiu Roibu
BrainMapper
Commits
10eab075
Commit
10eab075
authored
Aug 19, 2020
by
Andrei Roibu
Browse files
commented out calls to matplotlib.plt to prevent cluster errors
parent
76c6a42a
Changes
4
Show whitespace changes
Inline
Side-by-side
setup.py
View file @
10eab075
...
...
@@ -9,7 +9,6 @@ setup(
maintainer_email
=
'andrei-claudiu.roibu@dtc.ox.ac.uk'
,
install_requires
=
[
'pip'
,
'matplotlib'
,
'numpy'
,
'pandas'
,
'torch==1.4'
,
...
...
utils/DSbiobank.py
View file @
10eab075
...
...
@@ -17,7 +17,6 @@ Usage:
import
numpy
as
np
from
fsl.data.image
import
Image
from
fsl.utils.image.resample
import
resampleToPixdims
import
matplotlib.pyplot
as
plt
from
preprocessor
import
directory_reader
,
regression_weight_calculator
from
tempfile
import
TemporaryFile
from
datetime
import
datetime
...
...
utils/data_evaluation_utils.py
View file @
10eab075
...
...
@@ -21,7 +21,6 @@ import torch
import
logging
import
utils.data_utils
as
data_utils
from
utils.common_utils
import
create_folder
import
matplotlib.pyplot
as
plt
import
pandas
as
pd
from
fsl.data.image
import
Image
from
fsl.utils.image.roi
import
roi
...
...
@@ -511,39 +510,3 @@ def _pearson_correlation(volume, target):
np
.
sum
(
np
.
power
(
np
.
subtract
(
volume
,
volume
.
mean
()),
2
)),
np
.
sum
(
np
.
power
(
np
.
subtract
(
target
,
target
.
mean
()),
2
))))
return
r
def
_generate_correlation_matrix
(
correlation_matrix
,
title
,
prediction_output_path
,
normalize
=
False
):
"""Visual correlation matrix generator
This function generates a visual representation of the correlation matrix
Args:
correaltion_matrix (np.array): Array containing the correlation matrix
title (str): Title of the correlation matrix figure (also the experiment name)
normalize (bool): Flag indicating if the values of the correlation matrix should be normalized
prediction_output_path (str): Output prediction path
"""
# THIS FUNCTION NEEDS TO BE VERIFIED!
if
normalize
:
correlation_matrix
=
correlation_matrix
.
astype
(
'float'
)
/
correlation_matrix
.
sum
(
axis
=
1
)[:,
np
.
newaxis
]
plt
.
imshow
(
correlation_matrix
,
interpolation
=
'nearest'
,
cmap
=
plt
.
cm
.
Blues
)
plt
.
title
(
title
)
plt
.
colorbar
()
tick_marks
=
np
.
arange
(
len
(
correlation_matrix
))
plt
.
xticks
(
tick_marks
,
correlation_matrix
)
plt
.
yticks
(
tick_marks
,
correlation_matrix
)
threshold
=
correlation_matrix
.
max
()
/
2.0
for
i
,
j
in
itertools
.
product
(
range
(
correlation_matrix
.
shape
[
0
]),
range
(
correlation_matrix
.
shape
[
1
])):
plt
.
text
(
j
,
i
,
format
(
correlation_matrix
[
i
,
j
],
'.4f'
),
horizontalalignment
=
'center'
,
color
=
"white"
if
correlation_matrix
[
i
,
j
]
>
threshold
else
"black"
)
plt
.
tight_layout
()
plt
.
ylabel
(
'Predicted'
)
plt
.
xlabel
(
'Targets'
)
plt
.
savefig
(
prediction_output_path
+
'/'
+
title
+
'.png'
)
utils/data_logging_utils.py
View file @
10eab075
...
...
@@ -13,8 +13,6 @@ Usage:
"""
import
os
import
matplotlib
import
matplotlib.pyplot
as
plt
import
shutil
import
logging
import
numpy
as
np
...
...
@@ -24,11 +22,8 @@ import torch
# More here: https://tensorboardx.readthedocs.io/en/latest/tensorboard.html
from
tensorboardX
import
SummaryWriter
import
utils.data_evaluation_utils
as
evaluation
plt
.
axis
(
'scaled'
)
class
LogWriter
():
...
...
@@ -46,7 +41,7 @@ class LogWriter():
confusion_matrix_cmap (class): Colour Map to be used for the Conusion Matrix
"""
def
__init__
(
self
,
number_of_classes
,
logs_directory
,
experiment_name
,
use_last_checkpoint
=
False
,
labels
=
None
,
confusion_matrix_cmap
=
plt
.
cm
.
Blues
):
def
__init__
(
self
,
number_of_classes
,
logs_directory
,
experiment_name
,
use_last_checkpoint
=
False
,
labels
=
None
):
self
.
number_of_classes
=
number_of_classes
training_logs_directory
=
os
.
path
.
join
(
...
...
@@ -66,8 +61,6 @@ class LogWriter():
'validation'
:
SummaryWriter
(
logdir
=
validation_logs_directory
)
}
self
.
confusion_matrix_color_map
=
confusion_matrix_cmap
self
.
current_iteration
=
1
self
.
labels
=
[
'rsfMRI'
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment