-
Notifications
You must be signed in to change notification settings - Fork 134
WIP HBP-75 Merged plotting from tvb-scripts #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -34,47 +34,63 @@ | |
| """ | ||
|
|
||
| import os | ||
| import numpy as np | ||
| from datetime import datetime | ||
|
|
||
| import numpy | ||
|
|
||
|
|
||
| class GenericConfig(object): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not be here!!!! |
||
| _module_path = os.path.dirname(__file__) | ||
|
|
||
| # Identify and choose the Simulator, or data folder type to read. | ||
| MODE_H5 = "H5" | ||
| MODE_TVB = "TVB" | ||
|
|
||
|
|
||
| class InputConfig(object): | ||
| _base_input = os.getcwd() | ||
|
|
||
| @property | ||
| def HEAD(self): | ||
| if self._head_folder is not None: | ||
| return self._head_folder | ||
|
|
||
| # or else, try to find tvb_data module | ||
| try: | ||
| import tvb_data | ||
| return os.path.dirname(tvb_data.__file__) | ||
| except ImportError: | ||
| return self._base_input | ||
|
|
||
| @property | ||
| def IS_TVB_MODE(self): | ||
| """Identify and choose the Input data type to use""" | ||
| return self._data_mode == GenericConfig.MODE_TVB | ||
|
|
||
| @property | ||
| def RAW_DATA_FOLDER(self): | ||
| if self._raw_data is not None: | ||
| return self._raw_data | ||
|
|
||
| return os.path.join(self._base_input, "data", "raw") | ||
|
|
||
| def __init__(self, head_folder=None, raw_folder=None, data_mode=GenericConfig.MODE_TVB): | ||
| self._head_folder = head_folder | ||
| self._raw_data = raw_folder | ||
| self._data_mode = data_mode | ||
|
|
||
| class FiguresConfig(object): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have here under tvb.simulator.PLOT just a configuration for Figures. This is the single purpose for this module |
||
| VERY_LARGE_SIZE = (40, 20) | ||
| VERY_LARGE_PORTRAIT = (30, 50) | ||
| SUPER_LARGE_SIZE = (80, 40) | ||
| LARGE_SIZE = (20, 15) | ||
| SMALL_SIZE = (15, 10) | ||
| NOTEBOOK_SIZE = (10, 7) | ||
| FIG_FORMAT = 'png' | ||
| SAVE_FLAG = True | ||
| SHOW_FLAG = False | ||
| MOUSE_HOOVER = False | ||
| MATPLOTLIB_BACKEND = "Agg" # "Qt4Agg" | ||
| FONTSIZE = 10 | ||
| WEIGHTS_NORM_PERCENT = 99 | ||
| MAX_SINGLE_VALUE = np.finfo("single").max | ||
| MAX_INT_VALUE = np.iinfo(np.int64).max | ||
|
|
||
| class OutputConfig(object): | ||
| subfolder = None | ||
|
|
||
| def __init__(self, out_base=None, separate_by_run=False): | ||
| print(out_base) | ||
| print(separate_by_run) | ||
| """ | ||
| :param work_folder: Base folder where logs/figures/results should be kept | ||
| :param separate_by_run: Set TRUE, when you want logs/results/figures to be in different files / each run | ||
| """ | ||
| self._out_base = out_base or os.path.join(os.getcwd(), "outputs") | ||
| self._separate_by_run = separate_by_run | ||
|
|
||
| def largest_size(self): | ||
| import sys | ||
| if 'IPython' not in sys.modules: | ||
| return self.LARGE_SIZE | ||
| from IPython import get_ipython | ||
| if getattr(get_ipython(), 'kernel', None) is not None: | ||
| return self.NOTEBOOK_SIZE | ||
| else: | ||
| return self.LARGE_SIZE | ||
|
|
||
| @property | ||
| def FOLDER_LOGS(self): | ||
| folder = os.path.join(self._out_base, "logs") | ||
|
|
@@ -91,6 +107,8 @@ def FOLDER_RES(self): | |
| folder = folder + datetime.strftime(datetime.now(), '%Y-%m-%d_%H-%M') | ||
| if not (os.path.isdir(folder)): | ||
| os.makedirs(folder) | ||
| if self.subfolder is not None: | ||
| folder = os.path.join(folder, self.subfolder) | ||
| return folder | ||
|
|
||
| @property | ||
|
|
@@ -100,7 +118,63 @@ def FOLDER_FIGURES(self): | |
| folder = folder + datetime.strftime(datetime.now(), '%Y-%m-%d_%H-%M') | ||
| if not (os.path.isdir(folder)): | ||
| os.makedirs(folder) | ||
| if self.subfolder is not None: | ||
| os.path.join(folder, self.subfolder) | ||
| return folder | ||
|
|
||
| @property | ||
| def FOLDER_TEMP(self): | ||
| return os.path.join(self._out_base, "temp") | ||
|
|
||
|
|
||
| class FiguresConfig(object): | ||
| VERY_LARGE_SIZE = (40, 20) | ||
| VERY_LARGE_PORTRAIT = (30, 50) | ||
| SUPER_LARGE_SIZE = (80, 40) | ||
| LARGE_SIZE = (20, 15) | ||
| SMALL_SIZE = (15, 10) | ||
| NOTEBOOK_SIZE = (20, 10) | ||
| FIG_FORMAT = 'png' | ||
| SAVE_FLAG = True | ||
| SHOW_FLAG = False | ||
| MOUSE_HOOVER = False | ||
| MATPLOTLIB_BACKEND = "Agg" # "Qt4Agg" | ||
| FONTSIZE = 10 | ||
| SMALL_FONTSIZE = 8 | ||
| LARGE_FONTSIZE = 12 | ||
|
|
||
| def largest_size(self): | ||
| import sys | ||
| if 'IPython' not in sys.modules: | ||
| return self.LARGE_SIZE | ||
| from IPython import get_ipython | ||
| if getattr(get_ipython(), 'kernel', None) is not None: | ||
| return self.NOTEBOOK_SIZE | ||
| else: | ||
| return self.LARGE_SIZE | ||
|
|
||
|
|
||
| class CalculusConfig(object): | ||
| # Normalization configuration | ||
| WEIGHTS_NORM_PERCENT = 99 | ||
|
|
||
| # If True a plot will be generated to choose the number of eigenvalues to keep | ||
| INTERACTIVE_ELBOW_POINT = False | ||
|
|
||
| MIN_SINGLE_VALUE = numpy.finfo("single").min | ||
| MAX_SINGLE_VALUE = numpy.finfo("single").max | ||
| MAX_INT_VALUE = numpy.iinfo(numpy.int64).max | ||
| MIN_INT_VALUE = numpy.iinfo(numpy.int64).max | ||
|
|
||
|
|
||
| class Config(object): | ||
| generic = GenericConfig() | ||
| figures = FiguresConfig() | ||
| calcul = CalculusConfig() | ||
|
|
||
| def __init__(self, head_folder=None, raw_data_folder=None, output_base=None, separate_by_run=False): | ||
| self.input = InputConfig(head_folder, raw_data_folder) | ||
| self.out = OutputConfig(output_base, separate_by_run) | ||
|
|
||
|
|
||
| CONFIGURED = FiguresConfig() | ||
| CONFIGURED = Config() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code allowed more unity in the configurations. Currently, the fresh Config() in case of missing init param is always "fresh"