-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7f382c
commit f0a3128
Showing
7 changed files
with
179 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
"""Functions used for preprocessing.""" | ||
from neurots.preprocess import checkers # noqa | ||
|
||
# Copyright (C) 2022 Blue Brain Project, EPFL | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
from neurots.preprocess import relevancy_checkers # noqa | ||
from neurots.preprocess import validity_checkers # noqa | ||
from neurots.preprocess.utils import preprocess_inputs # noqa | ||
from neurots.preprocess.utils import register_preprocess # noqa | ||
from neurots.preprocess.utils import register_validator # noqa |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Functions to modify the given parameters and distributions before running the algorithm. | ||
The functions used as preprocesses should have a name like 'preprocess_*' and have the following | ||
signature: `check_something(params, distrs)`. These functions should be very generic and should | ||
not depend on any context in which the related grower is used. | ||
The preprocesses should be registered to be executed in the preprocess step using the | ||
`@register_preprocess` decorator. | ||
""" | ||
|
||
# Copyright (C) 2022 Blue Brain Project, EPFL | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
# TODO: remove the next line and the 'noqa' when a preprocess is added | ||
# pylint: disable=unused-import | ||
from neurots.preprocess.utils import register_preprocess # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""Functions to check that the given parameters and distributions will given relevant results. | ||
The functions used as relevancy checkers should have a name like 'check_*' and have the following | ||
signature: `check_something(params, distrs, start_point=None, context=None)`. The `start_point` and | ||
`context` parameters should always be optional, as they will not be known during the preprocessing | ||
step. | ||
""" | ||
|
||
# Copyright (C) 2022 Blue Brain Project, EPFL | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import logging | ||
|
||
L = logging.getLogger(__name__) | ||
|
||
|
||
def check_min_bar_length(params, distrs, start_point=None, context=None): | ||
"""Consistency check between parameters - persistence diagram.""" | ||
# pylint: disable=unused-argument | ||
barSZ = distrs["min_bar_length"] | ||
stepSZ = params["step_size"]["norm"]["mean"] | ||
if stepSZ >= barSZ: | ||
L.warning( | ||
"Selected step size %f is too big for bars of size %f", | ||
stepSZ, | ||
barSZ, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"""Functions to check that the given parameters and distributions will not break the algorithm. | ||
The functions used as validity checkers should have a name like 'check_*' and have the following | ||
signature: `check_something(params, distrs)`. These functions should be very generic and should | ||
not depend on any context in which the related grower is used. | ||
The checkers should be registered to be executed in the preprocess step using the | ||
`@register_validator` decorator. | ||
""" | ||
|
||
# Copyright (C) 2022 Blue Brain Project, EPFL | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
from neurots.preprocess.relevancy_checkers import check_min_bar_length | ||
from neurots.preprocess.utils import register_validator | ||
|
||
|
||
@register_validator("trunk") | ||
def check_num_seg(params, distrs): | ||
"""Check that params contains a 'num_seg' entry.""" | ||
# pylint: disable=unused-argument | ||
if "num_seg" not in params: | ||
raise KeyError( | ||
"The parameters must contain a 'num_seg' entry when the " | ||
"'growth_method' entry in parameters is 'trunk'." | ||
) | ||
|
||
|
||
@register_validator("tmd", "tmd_apical", "tmd_gradient") | ||
def check_bar_length(params, distrs): | ||
"""Check consistency between parameters and persistence diagram.""" | ||
if "min_bar_length" not in distrs: | ||
raise KeyError( | ||
"The distributions must contain a 'min_bar_length' entry when the " | ||
"'growth_method' entry in parameters is in ['tmd', 'tmd_apical', 'tmd_gradient']." | ||
) | ||
if "mean" not in params.get("step_size", {}).get("norm", {}): | ||
raise KeyError( | ||
"The parameters must contain a 'step_size' entry when the " | ||
"'growth_method' entry in parameters is in ['tmd', 'tmd_apical', 'tmd_gradient']." | ||
) | ||
check_min_bar_length(params, distrs) |