pylossless 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Scott Huberty
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,97 @@
1
+ Metadata-Version: 2.1
2
+ Name: pylossless
3
+ Version: 0.1.0
4
+ Summary: Python port of EEG-IP-L pipeline for preprocessing EEG.
5
+ Home-page: https://github.com/lina-usc/pylossless
6
+ Author: Scott Huberty
7
+ Author-email: seh33@uw.edu
8
+ Description-Content-Type: text/markdown
9
+ Provides-Extra: dash
10
+ Provides-Extra: test
11
+ Provides-Extra: doc
12
+ License-File: LICENSE
13
+
14
+
15
+ ![logo](./docs/source/_static/logo_white.png)
16
+
17
+
18
+ ![QCR Dashboard](./docs/source/_images/qc_screenshot.png)
19
+
20
+ # **Note: This software has ALPHA status. This means that this package is young and will likely undergo frequent changes and improvements. Please report any problems or bugs via a github issues ticket.**
21
+
22
+
23
+ - 🦾 Fully automated EEG processing pipeline built on MNE-Python.
24
+ - :recycle: Keeps your EEG recordings in their continuous state.
25
+ - 📝 Artifacts are annotated in your raw data.
26
+ - 👩‍💻 Use our dashboard to review the pipelines decisions on your files.
27
+
28
+
29
+
30
+ ## 📘 Installation and usage instructions
31
+
32
+ This package is not yet deployed on PyPI. It can therefore be installed with
33
+
34
+ ```bash
35
+ $ git clone git@github.com:lina-usc/pylossless.git
36
+ $ pip install --editable ./pylossless
37
+ ```
38
+ for an editable installation, or simply with
39
+ ```bash
40
+ $ pip install git+https://github.com/lina-usc/pylossless.git
41
+ ```
42
+ for a static version.
43
+
44
+ Please find the full documentation at
45
+ [**pylossless.readthedocs.io**](https://pylossless.readthedocs.io/en/latest/index.html).
46
+
47
+
48
+ ## ▶️ Running the pyLossless Pipeline
49
+ Below is a minimal example that runs the pipeline one of MNE's sample files.
50
+ ```
51
+ import pylossless as ll
52
+ import mne
53
+ fname = mne.datasets.sample.data_path() / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
54
+ raw = mne.io.read_raw_fif(fname, preload=True).pick_types(eeg=True) # pick EEG chans.
55
+
56
+ config = ll.config.Config()
57
+ config.load_default()
58
+ config.save("my_project_ll_config.yaml")
59
+
60
+ pipeline = ll.LosslessPipeline('my_project_ll_config.yaml')
61
+ pipeline.run_with_raw(raw)
62
+ ```
63
+
64
+ Once it is completed, You can see what channels and times were flagged:
65
+ ```
66
+ print(pipeline.flagged_chs)
67
+ print(pipeline.flagged_epochs)
68
+ ```
69
+
70
+ Once you are ready, you can save your file:
71
+ ```
72
+ pipeline.save(pipeline.get_derivative_path(bids_path), overwrite=True)
73
+ ```
74
+
75
+ ## 👩‍💻 Dashboard Review
76
+ ![QCR Dashboard](./docs/source/_images/qc_screenshot.png)
77
+
78
+ After running the Lossless pipeline, you can launch the Quality Control
79
+ Review (QC) dashboard to review the pipeline's decisions on each file!
80
+ You can flag additional channels, times and components, and edit flags
81
+ made by the pipeline.
82
+
83
+ First install the dashboard requirements
84
+ ```bash
85
+ $ cd ./path/to/pylossless/on/your/computer
86
+ $ pip install --editable .[dash]
87
+ ```
88
+
89
+ ```bash
90
+ $ python pylossless/dash/app.py
91
+ ```
92
+
93
+ ## Motivation
94
+
95
+ This project is a port of the MATLAB Lossless EEG Processing Pipeline ([Github repo](https://github.com/BUCANL/EEG-IP-L)) presented in [Desjardins et al (2021)](https://www.sciencedirect.com/science/article/pii/S0165027020303848). This port aims at 1) making this pipeline available to the Python community and 2) providing a version of the pipeline that is easier to deploy by outsiders.
96
+
97
+ This pipeline is built on the idea that sharing and pooling data across the scientific community is most efficient when sharing a standardized (e.g., in [BIDS](https://www.nature.com/articles/s41597-019-0104-8)) and "clean" version of a dataset. However, cleaning artifacts in a dataset generally results in a loss of data (i.e., the original recorded signals are generally not recoverable). This is particularly problematic given that preprocessing steps for a dataset are rarely perfect (i.e., future developments may offer methods that would perform better at removing some artifacts) and can be project-dependent. The Lossless pipeline addresses this issue by proposing a "lossless" process where data are annotated for artifacts in a non-destructive way, so that users have access to a readily clean dataset if they are comfortable with the existing annotations. Alternative, they can choose which annotations to use for preprocessing in a piecemeal fashion, or simply use the raw data without excluding any artifacts based on provided annotations. Artifacts are annotated for channels, epochs, and independent components; see [Desjardins et al (2021)](https://www.sciencedirect.com/science/article/pii/S0165027020303848) for a more detailed presentation.
@@ -0,0 +1,84 @@
1
+
2
+ ![logo](./docs/source/_static/logo_white.png)
3
+
4
+
5
+ ![QCR Dashboard](./docs/source/_images/qc_screenshot.png)
6
+
7
+ # **Note: This software has ALPHA status. This means that this package is young and will likely undergo frequent changes and improvements. Please report any problems or bugs via a github issues ticket.**
8
+
9
+
10
+ - 🦾 Fully automated EEG processing pipeline built on MNE-Python.
11
+ - :recycle: Keeps your EEG recordings in their continuous state.
12
+ - 📝 Artifacts are annotated in your raw data.
13
+ - 👩‍💻 Use our dashboard to review the pipelines decisions on your files.
14
+
15
+
16
+
17
+ ## 📘 Installation and usage instructions
18
+
19
+ This package is not yet deployed on PyPI. It can therefore be installed with
20
+
21
+ ```bash
22
+ $ git clone git@github.com:lina-usc/pylossless.git
23
+ $ pip install --editable ./pylossless
24
+ ```
25
+ for an editable installation, or simply with
26
+ ```bash
27
+ $ pip install git+https://github.com/lina-usc/pylossless.git
28
+ ```
29
+ for a static version.
30
+
31
+ Please find the full documentation at
32
+ [**pylossless.readthedocs.io**](https://pylossless.readthedocs.io/en/latest/index.html).
33
+
34
+
35
+ ## ▶️ Running the pyLossless Pipeline
36
+ Below is a minimal example that runs the pipeline one of MNE's sample files.
37
+ ```
38
+ import pylossless as ll
39
+ import mne
40
+ fname = mne.datasets.sample.data_path() / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
41
+ raw = mne.io.read_raw_fif(fname, preload=True).pick_types(eeg=True) # pick EEG chans.
42
+
43
+ config = ll.config.Config()
44
+ config.load_default()
45
+ config.save("my_project_ll_config.yaml")
46
+
47
+ pipeline = ll.LosslessPipeline('my_project_ll_config.yaml')
48
+ pipeline.run_with_raw(raw)
49
+ ```
50
+
51
+ Once it is completed, You can see what channels and times were flagged:
52
+ ```
53
+ print(pipeline.flagged_chs)
54
+ print(pipeline.flagged_epochs)
55
+ ```
56
+
57
+ Once you are ready, you can save your file:
58
+ ```
59
+ pipeline.save(pipeline.get_derivative_path(bids_path), overwrite=True)
60
+ ```
61
+
62
+ ## 👩‍💻 Dashboard Review
63
+ ![QCR Dashboard](./docs/source/_images/qc_screenshot.png)
64
+
65
+ After running the Lossless pipeline, you can launch the Quality Control
66
+ Review (QC) dashboard to review the pipeline's decisions on each file!
67
+ You can flag additional channels, times and components, and edit flags
68
+ made by the pipeline.
69
+
70
+ First install the dashboard requirements
71
+ ```bash
72
+ $ cd ./path/to/pylossless/on/your/computer
73
+ $ pip install --editable .[dash]
74
+ ```
75
+
76
+ ```bash
77
+ $ python pylossless/dash/app.py
78
+ ```
79
+
80
+ ## Motivation
81
+
82
+ This project is a port of the MATLAB Lossless EEG Processing Pipeline ([Github repo](https://github.com/BUCANL/EEG-IP-L)) presented in [Desjardins et al (2021)](https://www.sciencedirect.com/science/article/pii/S0165027020303848). This port aims at 1) making this pipeline available to the Python community and 2) providing a version of the pipeline that is easier to deploy by outsiders.
83
+
84
+ This pipeline is built on the idea that sharing and pooling data across the scientific community is most efficient when sharing a standardized (e.g., in [BIDS](https://www.nature.com/articles/s41597-019-0104-8)) and "clean" version of a dataset. However, cleaning artifacts in a dataset generally results in a loss of data (i.e., the original recorded signals are generally not recoverable). This is particularly problematic given that preprocessing steps for a dataset are rarely perfect (i.e., future developments may offer methods that would perform better at removing some artifacts) and can be project-dependent. The Lossless pipeline addresses this issue by proposing a "lossless" process where data are annotated for artifacts in a non-destructive way, so that users have access to a readily clean dataset if they are comfortable with the existing annotations. Alternative, they can choose which annotations to use for preprocessing in a piecemeal fashion, or simply use the raw data without excluding any artifacts based on provided annotations. Artifacts are annotated for channels, epochs, and independent components; see [Desjardins et al (2021)](https://www.sciencedirect.com/science/article/pii/S0165027020303848) for a more detailed presentation.
@@ -0,0 +1,4 @@
1
+ """Python port of EEG-IP-L pipeline for preprocessing EEG."""
2
+
3
+ from . import pipeline, config, bids
4
+ from .pipeline import LosslessPipeline
@@ -0,0 +1,68 @@
1
+ import time
2
+
3
+ from mne.utils import logger
4
+ from functools import wraps
5
+
6
+ CONF_MAP = {'run_staging_script': 'staging_script',
7
+ 'find_breaks': 'find_breaks'}
8
+
9
+
10
+ def _is_step_run(func, instance):
11
+ """Check if step was run."""
12
+ if func.__name__ in ['run_staging_script', 'find_breaks']:
13
+ step = CONF_MAP[func.__name__]
14
+ return (True if
15
+ step not in instance.config or not instance.config[step]
16
+ else False)
17
+ else:
18
+ return False
19
+
20
+
21
+ def lossless_logger(func=None, *, message=None, verbose=True):
22
+ """Handle start and completion logging for pipeline steps.
23
+
24
+ Parameters
25
+ ----------
26
+ func
27
+ pipeline method to be logged
28
+ message : str
29
+ message about the step being run to provide to user
30
+ verbose : bool
31
+ if True, print logging message. if False, suppress logging
32
+ message.
33
+ """
34
+ if func is None:
35
+ return lambda f: lossless_logger(f, message=message)
36
+
37
+ @wraps(func)
38
+ def wrapper(*args, message=None, **kwargs):
39
+ start_time = time.time()
40
+ instance = args[0]
41
+ skip = _is_step_run(func, instance)
42
+ this_step = message if message is not None else func.__name__
43
+ if skip:
44
+ logger.info(f"LOSSLESS: Skipping {this_step}")
45
+ return
46
+ elif verbose:
47
+ logger.info(f"LOSSLESS: 🚩 {this_step}.")
48
+ result = func(*args, **kwargs)
49
+ end_time = time.time()
50
+ dur = f"{end_time - start_time:.2f}"
51
+ if verbose:
52
+ logger.info(f"LOSSLESS: 🏁 Finished {this_step} after {dur}"
53
+ " seconds.")
54
+ return result
55
+ return wrapper
56
+
57
+
58
+ def lossless_time(func):
59
+ """Log the time of a full pipeline run."""
60
+ def wrapper(*args, **kwargs):
61
+ logger.info(" ⏩ LOSSLESS: Starting Pylossless Pipeline.")
62
+ start_time = time.time()
63
+ result = func(*args, **kwargs)
64
+ end_time = time.time()
65
+ dur = f"{(end_time - start_time) / 60:.2f}"
66
+ logger.info(f" ✅ LOSSLESS: Pipeline completed! took {dur} minutes.")
67
+ return result
68
+ return wrapper
@@ -0,0 +1,136 @@
1
+ # Authors: Christian O'Reilly <christian.oreilly@sc.edu>
2
+ # Scott Huberty <seh33@uw.edu>
3
+ # Tyler Collins <collins.tyler.k@gmail.com>
4
+ #
5
+ # License: MIT
6
+
7
+ """Helper functions for extending mne_bids functionality."""
8
+
9
+ from mne_bids import BIDSPath, write_raw_bids
10
+
11
+
12
+ # TODO: Add parameters and return.
13
+ def get_bids_path(bids_path_kwargs,
14
+ datatype='eeg',
15
+ bids_root='./bids_dataset'):
16
+ """Get BIDS path from BIDS recording."""
17
+ if "datatype" not in bids_path_kwargs:
18
+ bids_path_kwargs["datatype"] = datatype
19
+ if "root" not in bids_path_kwargs:
20
+ bids_path_kwargs["root"] = bids_root
21
+
22
+ return BIDSPath(**bids_path_kwargs)
23
+
24
+
25
+ # TODO: Add parameters and return.
26
+ def get_dataset_bids_path(bids_path_args,
27
+ datatype='eeg',
28
+ bids_root='./bids_dataset'):
29
+ """Getter method for BIDS path from BIDS dataset."""
30
+ return [get_bids_path(bids_path_kwargs, datatype, bids_root)
31
+ for bids_path_kwargs in bids_path_args]
32
+
33
+
34
+ def convert_recording_to_bids(import_func, import_kwargs, bids_path_kwargs,
35
+ datatype='eeg', bids_root='./bids_dataset',
36
+ import_events=True, **write_kwargs):
37
+ """Convert a dataset to BIDS.
38
+
39
+ Parameters
40
+ ----------
41
+ import_func : function
42
+ This function when called, will take as keyword arguments the
43
+ dictionary `import_args`. If `import_events` set to True, this
44
+ function must return 1) an object of type `mne.io.Raw`, 2) a structure
45
+ of events (specified as usual in MNE-Python), and 3) a event_id
46
+ dictionary (specified as usual in MNE-Python). If `import_events` is
47
+ set to False, this function must return an object of the `mne.io.Raw`
48
+ class.
49
+ import_kwargs : dict
50
+ Dictionary of the keyword arguments necessary to be passed to
51
+ `import_fct` to successfully import the corresponding recording.
52
+ bids_path_kwargs : dict
53
+ Dictionary of the keyword arguments necessary to be passed to the
54
+ constructor of the `mne_bids.BIDSPath` class.
55
+ import events: boolean
56
+ Whether to import a provided events object
57
+ Returns
58
+ -------
59
+ bids_paths : list of instance of `mne_bids.BIDSPath`
60
+ `mne_bids.BIDSPath` for the different recordings
61
+ """
62
+ bids_path = get_bids_path(bids_path_kwargs, datatype, bids_root)
63
+ if import_events:
64
+ raw, events, event_id = import_func(**import_kwargs)
65
+ else:
66
+ raw = import_func(**import_kwargs)
67
+ events = None
68
+ event_id = None
69
+
70
+ if "format" not in write_kwargs:
71
+ write_kwargs["format"] = "EDF"
72
+ if "allow_preload" not in write_kwargs:
73
+ write_kwargs["allow_preload"] = True
74
+
75
+ write_raw_bids(raw, bids_path=bids_path,
76
+ events_data=events, event_id=event_id,
77
+ **write_kwargs)
78
+
79
+ return bids_path
80
+
81
+
82
+ def convert_dataset_to_bids(import_funcs, import_args, bids_path_args,
83
+ datatype='eeg', bids_root='./bids_dataset',
84
+ import_events=True, **write_kwargs):
85
+ """Convert a dataset to BIDS.
86
+
87
+ Parameters
88
+ ----------
89
+ import_fct : function or list of functions
90
+ This function when called, will take as keyword arguments one of the
91
+ dictionaries in the `import_args` list. If `import_events` set to True,
92
+ this function must return 1) an object of type `mne.io.Raw`, 2) a
93
+ structure of events (specified as usual in MNE-Python), and 3) a
94
+ event_id dictionary (specified as usual in MNE-Python). if
95
+ `import_events` set to False, this function must return an object of the
96
+ `mne.io.Raw` class. This argument can also be a list of functions, in
97
+ case where, for example, different recordings have different formats and
98
+ require different import functions. In this case, the length of this
99
+ attribute must be the same as `import_args`.
100
+ import_args : list of dict
101
+ Each item of this list needs to be a dictionary of the keyword
102
+ arguments necessary to be passed to `import_fct` to successfully import
103
+ the corresponding recording. This list needs to be of the same length
104
+ as bids_path_args.
105
+ bids_path_args : list of dict
106
+ Each item of this list needs to be a dictionary of the keyword
107
+ arguments necessary to be passed to the constructor of the
108
+ `mne_bids.BIDSPath` class. This list needs to be of the same length
109
+ as import_args.
110
+ import events: boolean
111
+ Whether to import a provided events object.
112
+ Returns
113
+ -------
114
+ bids_paths : list of instance of `mne_bids.BIDSPath`
115
+ `mne_bids.BIDSPath` for the different recordings
116
+ """
117
+ assert (len(import_args) == len(bids_path_args))
118
+ if isinstance(import_funcs, list):
119
+ assert (len(import_args) == len(import_funcs))
120
+ else:
121
+ import_funcs = [import_funcs]*len(import_args)
122
+
123
+ bids_paths = []
124
+ for import_kwargs, bids_path_kwargs, func in zip(import_args,
125
+ bids_path_args,
126
+ import_funcs):
127
+ bids_paths.append(
128
+ convert_recording_to_bids(func,
129
+ import_kwargs,
130
+ bids_path_kwargs,
131
+ datatype=datatype,
132
+ bids_root=bids_root,
133
+ import_events=import_events,
134
+ **write_kwargs))
135
+
136
+ return bids_paths
@@ -0,0 +1,48 @@
1
+ # Authors: Christian O'Reilly <christian.oreilly@sc.edu>
2
+ # Scott Huberty <seh33@uw.edu>
3
+ # Tyler Collins <collins.tyler.k@gmail.com>
4
+ #
5
+ # License: MIT
6
+
7
+ """Module file contains Config class which defines procedures."""
8
+
9
+ import sys
10
+ from pathlib import Path
11
+ import yaml
12
+
13
+
14
+ # TODO: Add parameters and references for below functions.
15
+ # TODO: Add magic methods and constructors for this class.
16
+ class Config(dict):
17
+ """Representation of configuration files for a pipeline procedure."""
18
+
19
+ DEFAULT_CONFIG_PATH = (Path(__file__).parent.parent /
20
+ "assets" / "ll_default_config.yaml")
21
+
22
+ def read(self, file_name):
23
+ """Read a saved pylossless config file."""
24
+ file_name = Path(file_name)
25
+ if not file_name.exists():
26
+ raise FileExistsError(f'Configuration file {file_name.absolute()} '
27
+ 'does not exist')
28
+
29
+ with file_name.open("r") as init_variables_file:
30
+ self.update(yaml.safe_load(init_variables_file))
31
+
32
+ return self
33
+
34
+ def load_default(self):
35
+ """Get the default pylossless config file."""
36
+ self.read(Config.DEFAULT_CONFIG_PATH)
37
+ return self
38
+
39
+ def save(self, file_name):
40
+ """Save the current Config object to disk."""
41
+ file_name = Path(file_name)
42
+ with file_name.open("w") as init_variables_file:
43
+ yaml.dump(dict(self), init_variables_file,
44
+ indent=4, sort_keys=True)
45
+
46
+ def print(self):
47
+ """Print the Config contents."""
48
+ yaml.dump(dict(self), sys.stdout, indent=4, sort_keys=True)
@@ -0,0 +1,8 @@
1
+ """Dash based helper functions for Lossless QC procedure."""
2
+
3
+ from mne_icalabel.config import ICLABEL_LABELS_TO_MNE
4
+
5
+ IC_COLORS = ['#2c2c2c', '#003e83', 'cyan', 'goldenrod', 'magenta', '#b08699',
6
+ '#96bfe6', 'brown', 'yellowgreen', 'burlywood', 'plum']
7
+
8
+ ic_label_cmap = dict(zip(ICLABEL_LABELS_TO_MNE.values(), IC_COLORS))
@@ -0,0 +1,25 @@
1
+ # Authors: Christian O'Reilly <christian.oreilly@sc.edu>
2
+ # Scott Huberty <seh33@uw.edu>
3
+ # License: MIT
4
+
5
+ """Launching point for Lossless QC Dash app."""
6
+ import dash
7
+ import dash_bootstrap_components as dbc
8
+ from pylossless.dash.qcgui import QCGUI
9
+
10
+
11
+ def get_app(fpath=None, project_root=None, disable_buttons=False, kind="dash"):
12
+ """Call either Dash or Jupyter for Lossless QC procedure."""
13
+ if kind == "jupyter":
14
+ from jupyter_dash import JupyterDash
15
+ app = JupyterDash(__name__, external_stylesheets=[dbc.themes.SLATE])
16
+ else:
17
+ app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SLATE])
18
+
19
+ QCGUI(app, fpath=fpath, project_root=project_root,
20
+ disable_buttons=disable_buttons)
21
+ return app
22
+
23
+
24
+ if __name__ == '__main__':
25
+ get_app().run_server(debug=False, use_reloader=False)
@@ -0,0 +1,148 @@
1
+ """CSS styling constant for Lossless Pipeline in Dash."""
2
+
3
+ # Author: Scott Huberty <seh33@uw.edu>
4
+
5
+ # Default Layout for individual scatter plots within timeseries
6
+ ###############################################################
7
+
8
+ drawn_shapes_format = {"drawdirection": "vertical",
9
+ "layer": "below",
10
+ "fillcolor": "red",
11
+ "opacity": 0.51,
12
+ "line": {"width": 0}}
13
+
14
+ drawn_selections_format = {'line': dict(color='crimson', width=2)}
15
+
16
+
17
+ DEFAULT_LAYOUT_XAXIS = {'zeroline': False,
18
+ 'showgrid': True,
19
+ 'title': "time (seconds)",
20
+ 'gridcolor': 'white',
21
+ 'fixedrange': True,
22
+ 'showline': True,
23
+ 'titlefont': dict(color='#ADB5BD'),
24
+ 'tickfont': dict(color='#ADB5BD'),
25
+ 'automargin': True
26
+ }
27
+
28
+ DEFAULT_LAYOUT_YAXIS = {'showgrid': True,
29
+ 'showline': True,
30
+ 'zeroline': False,
31
+ 'autorange': False, # 'reversed',
32
+ 'scaleratio': 0.5,
33
+ "tickmode": "array",
34
+ 'titlefont': dict(color='#ADB5BD'),
35
+ 'tickfont': dict(color='#ADB5BD'),
36
+ 'fixedrange': True,
37
+ 'automargin': True}
38
+
39
+ DEFAULT_LAYOUT = dict( # height=400,
40
+ # width=850,
41
+ xaxis=DEFAULT_LAYOUT_XAXIS,
42
+ yaxis=DEFAULT_LAYOUT_YAXIS,
43
+ showlegend=False,
44
+ margin={'t': 15, 'b': 0, 'l': 35, 'r': 5},
45
+ # {'t': 15,'b': 25, 'l': 35, 'r': 5},
46
+ paper_bgcolor="rgba(0,0,0,0)",
47
+ plot_bgcolor="#EAEAF2",
48
+ shapes=[],
49
+ dragmode='select',
50
+ newshape=drawn_shapes_format,
51
+ newselection=drawn_selections_format,
52
+ activeshape=dict(fillcolor='crimson', opacity=.75),
53
+ hovermode='closest')
54
+
55
+ WATERMARK_ANNOT = (dict(text='NO FILE SELECTED',
56
+ textangle=0, opacity=0.1,
57
+ font=dict(color='red', size=80),
58
+ xref='paper', yref='paper', x=.5, y=.5,
59
+ showarrow=False),
60
+ )
61
+
62
+ CSS = dict()
63
+ STYLE = dict()
64
+
65
+
66
+ ####################################################
67
+ # TIMESERIES
68
+ ####################################################
69
+
70
+ # bootstrap for channel slider: self.channel_slider
71
+ # Empty
72
+
73
+ # bootstrap format for channel slider div: self.channel_slider_div
74
+ CSS['ch-slider-div'] = "d-inline-block align-top"
75
+
76
+ # bootstrap format for time slider
77
+ # Empty
78
+
79
+ # bootstrap for time slider div
80
+ CSS['time-slider-div'] = "w-100"
81
+
82
+ # bootstrap for timeseries: self.graph
83
+ CSS['timeseries'] = "w-100 d-inline-block" # border border-info
84
+ STYLE['timeseries'] = {'height': '40vh'}
85
+
86
+ # bootstrap for timeseries-div: self.graph_div; border border-warnings
87
+ CSS['timeseries-div'] = "mh-100 d-inline-block shadow-lg"
88
+ STYLE['timeseries-div'] = {'width': '95%'}
89
+
90
+ # bootstrap for timeseries-container: self.container_plot
91
+
92
+ CSS['timeseries-container'] = "w-100" # border border-success
93
+
94
+ ############################################################
95
+ # TOPO PLOTS
96
+ ############################################################
97
+
98
+ # bootstrap format for topo slider div
99
+ CSS['topo-slider-div'] = "d-inline-block align-middle"
100
+
101
+ # bootstrap for topo dcc-graph
102
+ CSS['topo-dcc'] = "bg-secondary bg-opacity-50 border rounded" # border-info
103
+
104
+ # bootstrap for div containing topo-dcc; border border-warning
105
+ CSS['topo-dcc-div'] = 'bg-secondary bg-opacity-50 d-inline-block align-top'
106
+ STYLE['topo-dcc-div'] = {'width': '90%'} # so that slider can fit to the left
107
+
108
+ # bootstrap for final container: self.container_plot
109
+ CSS['topo-container'] = 'topo-div shadow-lg' # border border-success
110
+
111
+ #####################
112
+ # QC DASHBOARD LAYOUT
113
+ #####################
114
+
115
+ # QC container
116
+ STYLE['qc-container'] = {} # {'border': '2px solid yellow'}
117
+
118
+ # File control Row
119
+ CSS['file-row'] = 'h-20'
120
+ # STYLE['file-row'] = {'border': '2px solid orange'}
121
+
122
+ # Select Folder & Save Button Col
123
+ # STYLE['folder-col'] = {'border': '2px solid red'}
124
+
125
+ # Select Folder & Save Buttons
126
+ CSS['button'] = "d-md-inline-block"
127
+
128
+ # Dropdown Col
129
+ # STYLE['dropdown-col'] = {'border': '2px dashed purple'}
130
+
131
+ # Dropdown
132
+ CSS['dropdown'] = "d-md-inline-block w-100"
133
+
134
+ # Logo Col
135
+ # Empty
136
+
137
+ # Logo
138
+ CSS['logo'] = 'ms-5 mh-100'
139
+
140
+ # Timeseries & Topo bootstrap Row
141
+ CSS['plots-row'] = 'h-80'
142
+ STYLE['plots-row'] = {} # {'border': '2px dashed pink'}
143
+
144
+ # Timeseries plots Col
145
+ CSS['timeseries-col'] = 'w-100 h-100 mh-100'
146
+
147
+ # Topoplots Col
148
+ CSS['topo-col'] = 'h-100 mt-2 mb-2' # border border-danger