From 1e2787c6699f29937b687d1e103be6aeaf46fef6 Mon Sep 17 00:00:00 2001 From: devonJarvis Date: Sun, 30 Jul 2023 14:37:30 +0100 Subject: [PATCH 1/6] Added style guide branch to edit on github --- documents/style_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documents/style_guide.md b/documents/style_guide.md index 3b7d9835..9062c1ed 100644 --- a/documents/style_guide.md +++ b/documents/style_guide.md @@ -1,4 +1,4 @@ -# Style Guide +# Style Guide We are following to the best of our abilities the [PEP8](https://www.python.org/dev/peps/pep-0008/) and [numpy docstring](https://numpydoc.readthedocs.io/en/latest/format.html) style convention. Note: Pycharm has an inbuild checking framework that will help you follow the style guide. The pre-commit bot will enforces these style guide requierements. From 151931f1561995e35198821104f0133b6108dc43 Mon Sep 17 00:00:00 2001 From: Devon Jarvis <30460455+JarvisDevon@users.noreply.github.com> Date: Sun, 30 Jul 2023 15:48:52 +0100 Subject: [PATCH 2/6] Started adding style of experiments --- documents/style_guide.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/documents/style_guide.md b/documents/style_guide.md index 9062c1ed..e9612417 100644 --- a/documents/style_guide.md +++ b/documents/style_guide.md @@ -335,3 +335,8 @@ Additionally your class will also inherit the necessary methods that the rest of > - Description: Number of time steps maintained in the render of the history. > - Returns: None > - Description: Render the environment live through iterations. + +## Experiment +Implementing a style format for experimental classes is more complex due to the wide variety of data formats and experimental setups. For consistency and ease of future development, when creating a new experimental class the `Experiment` class should be inherited from "experiment_core.py". However, for the moment this class remains empty and provides no variables or functionality. It then becomes key that the steps described in [How To Contribute](https://github.com/SainsburyWellcomeCentre/NeuralPlayground/tree/main/neuralplayground/experiments#3-how-to-contribute) are followed. In particular providing a minimal example of the functionality offered by the class in [Examples](https://github.com/ClementineDomine/NeuralPlayground/tree/main/examples/experimental_examples/) is very important. This allows for future developers to easily use the class (without having a base class available to extrapolate from) but also to find similarities between experimental classes. For example [Hafting2008Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/hafting_2008_data.py) offers a simple class for 2D Experimental data. Consequently our implementation of [Sargolini2006Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/sargolini_2006_data.py) inherits from [Hafting2008Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/hafting_2008_data.py). This is ideal and aligns well with the motivation of this package - to begin to standardise the presentation and interface with neuroscience research. For the purpose of example we will describe the style of [Hafting2008Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/hafting_2008_data.py). + +### Hafting2008Data From 494690749503a8536d03a15d4b4aae495f6820a3 Mon Sep 17 00:00:00 2001 From: Devon Jarvis <30460455+JarvisDevon@users.noreply.github.com> Date: Sun, 30 Jul 2023 16:12:43 +0100 Subject: [PATCH 3/6] Working on Hafting style --- documents/style_guide.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/documents/style_guide.md b/documents/style_guide.md index e9612417..6a58e2b2 100644 --- a/documents/style_guide.md +++ b/documents/style_guide.md @@ -339,4 +339,35 @@ Additionally your class will also inherit the necessary methods that the rest of ## Experiment Implementing a style format for experimental classes is more complex due to the wide variety of data formats and experimental setups. For consistency and ease of future development, when creating a new experimental class the `Experiment` class should be inherited from "experiment_core.py". However, for the moment this class remains empty and provides no variables or functionality. It then becomes key that the steps described in [How To Contribute](https://github.com/SainsburyWellcomeCentre/NeuralPlayground/tree/main/neuralplayground/experiments#3-how-to-contribute) are followed. In particular providing a minimal example of the functionality offered by the class in [Examples](https://github.com/ClementineDomine/NeuralPlayground/tree/main/examples/experimental_examples/) is very important. This allows for future developers to easily use the class (without having a base class available to extrapolate from) but also to find similarities between experimental classes. For example [Hafting2008Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/hafting_2008_data.py) offers a simple class for 2D Experimental data. Consequently our implementation of [Sargolini2006Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/sargolini_2006_data.py) inherits from [Hafting2008Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/hafting_2008_data.py). This is ideal and aligns well with the motivation of this package - to begin to standardise the presentation and interface with neuroscience research. For the purpose of example we will describe the style of [Hafting2008Data](https://github.com/ClementineDomine/NeuralPlayground/blob/main/neuralplayground/experiments/hafting_2008_data.py). -### Hafting2008Data +### hafting_2008_data.py +The original article of Hafting et al. 2008. can be found at https://www.nature.com/articles/nature06957. The data can be obtained from https://archive.norstore.no/pages/public/datasetDetail.jsf?id=C43035A4-5CC5-44F2-B207-126922523FD9. This class only consider animal raw animal trajectories and neural recordings. + +The class does not contain its own attributes and only provides functions which interface with the data. These functions are: +> * `__init__( )` +> - Accepts: +> - `data_path` : *str* +> - Default: `None` +> - Description: If `None` then fetch the data from the NeuralPlayground data repository, else load data from the given path. +> - `recording_index` : *int* +> - Default: `None` +> - Description: If `None` then load data from default recording index. +> - `experiment_name`: *str* +> - Default: "FullHaftingData" +> - Description: A string to identify the object in case multiple instances of the class are being used. +> - `verbose`: *bool* +> - Default: `False` +> - Description: If `True` then it will print original readme and data structure when initializing this object. +> - Returns: None +> - Description: Function which initialises an object of the class. Providing no inputs will default the object to reload the dataset from the repositories. +> +> * `set_animal_data()` +> - Accepts: +> - `recording_index`: *int* +> - Default: `0` +> - Description: Provides a unique digit for the recording. +> - `tolerance`: *float* +> - Default: `1e-10` +> - Description: Degree of allowable deviation or variance when calculating the head direction. +> - Returns: `None` +> - Description: Set position and head direction of the animal to be used by an Arena-based class later. +> From 10e4ca812dd322c437c4a52b4bc8d5488fea1b32 Mon Sep 17 00:00:00 2001 From: Devon Jarvis <30460455+JarvisDevon@users.noreply.github.com> Date: Sun, 30 Jul 2023 18:15:33 +0100 Subject: [PATCH 4/6] Working on experiments style guide --- documents/style_guide.md | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/documents/style_guide.md b/documents/style_guide.md index 6a58e2b2..d6b08da9 100644 --- a/documents/style_guide.md +++ b/documents/style_guide.md @@ -371,3 +371,117 @@ The class does not contain its own attributes and only provides functions which > - Returns: `None` > - Description: Set position and head direction of the animal to be used by an Arena-based class later. > +> * `_find_data_path()` +> - Accepts: +> - `data_path`: *str* +> - Default: `None` +> - Description: File path to data. +> - Returns: `None` +> - Description: Fetch data from NeuralPlayground data repository if no data path is supplied by the user or fetches the data from the path. +> +> * `_load_data()` +> - Accepts: `None` +> - Returns: `None` +> - Description: Parse data according to specific data format. If you are a user check the notebook examples. +> +> * `_create_dataframe()` +> - Accepts: `None` +> - Returns: `None` +> - Description: Generates dataframe for easy display and access of data. +> +> * `show_data()` +> - Accepts: +> - `full_dataframe`: *bool* +> - Default: `False` +> - Description: If True then it will show all available data, a small sample otherwise +> - Returns: +> - `recording_list`: *Pandas dataframe* +> - Description: List of available data, columns with rat_id, recording session and recorded variables +> - Description: Print of available data recorded in the experiment. +> +> * `show_readme()` +> - Accepts: `None` +> - Returns: `None` +> - Description: Print original readme of the dataset. +> +> * `get_recorded_session()` +> - Accepts: +> - `recording_index`: *int* +> - Default: `None` +> - Description: Recording identifier, index in pandas dataframe with listed data +> - Returns: +> - `rat_id`: *str* +> - Description: The rat identifier from experiment +> - `sess`: *str* +> - Description: The recording session identifier from experiment +> - `recorded_vars`: *list of str* +> - Description: Variables recorded from a given session +> - Description: Get identifiers to sort the experimental data. +> +> * `get_recording_data()` +> - Accepts: +> - `recording_index`: *int* +> - Default: `None` +> - Description: The recording identifier - an index in the pandas dataframe with listed data +> - Returns: +> - `session_data`: *dict* +> - Description: Dictionary with recorded raw data from the session of the respective recording index. Format of this data follows original readme from the authors of the experiments. +> - `rec_vars`: *list of str* +> - Description: The keys of session_data dict and recorded variables for a given session +> - `identifiers`: *dict* +> - Description: Dictionary with rat_id and session_id of the returned session data +> - Description: Get experimental data for a given recordin index. +> +> * `_find_tetrode()` +> - Accepts: +> - `rev_vars`: *list of strings* +> - Description: The recorded variables for a given session, tetrode id within it +> - Returns: +> - `tetrode_id`: *str* +> - Description: The first tetrode id which is found in the recorded variable list. +> - Description: Static function to find tetrode id in a multiple tetrode recording session. +> +> * `get_tetrode_data()` +> - Accepts: +> - `session_data`: *str* +> - Default: `None` +> - Description: If None the the session used corresponds to the default recording index +> - `tetrode_id`: *str* +> - Default: `None` +> - Description: The tetrode id in the corresponding session +> - Returns: +> - `time_array`: *ndarray* +> - Description: The array with the timestamps in seconds per position of the given session. +> - `test_spikes`: *ndarray* +> - Description: The spike times in seconds of the given session. +> - `x`: *ndarray* +> - Description: The x position throughout recording of the given session. +> - `y`: *ndarray* +> - Description: The y position throughout recording of the given session. +> - Description: Return time stamp, position and spikes for a given session and tetrode. +> +> * `plot_recording_tetr()` +> - Accepts: +> - `recording_index`: *int, tuple of ints, list of ints* +> - Default: `None` +> - Description: The recording index to plot spike ratemap, if list or tuple, it will recursively call this function to make a plot per recording index. If this argument is list or tuple, the rest of variables must be list or tuple with their respective types, or keep the default None value. +> - `save_path`: *str, list of str, tuple of str* +> - Default: `None` +> - Description: The saving path of the generated figure. If None then no figure is saved +> - `ax`: *mpl.axes._subplots.AxesSubplot, list of ax, or tuple of ax* +> - Default: `None` +> - Description: An axis or list of axis from subplot from matplotlib where the ratemap will be plotted. If None, ax is generated with default options. +> - `tetrode_id`: *str, list of str, or tuple of str* +> - Default: `None` +> - Description: tetrode id in the corresponding session. +> - `bin_size`: *float* +> - Default: `2.0` +> - Description: The bin size to discretize space when computing ratemap +> - Returns: +> - `h`: *ndarray (nybins, nxbins)* +> - Description: Number of spikes falling on each bin through the recorded session, nybins number of bins in y axis, nxbins number of bins in x axis (returned as list or tupe depending on the argument type). +> - `binx`: *ndarray (nxbins +1,)* +> - Description: The bin limits of the ratemap on the x axis (returned as list or tupe depending on the argument type). +> - `biny`: *ndarray (nybins +1,)* +> - Description: The bin limits of the ratemap on the y axis (returned as list or tupe depending on the argument type). +> - Description: Plot tetrode ratemap from spike data for a given recording index or a list of recording index. If given a list or tuple as argument, all arguments must be list, tuple, or None. From 4a5e8dc1e39a7c91d55ea4c5e1e8d05d3513ea02 Mon Sep 17 00:00:00 2001 From: Devon Jarvis <30460455+JarvisDevon@users.noreply.github.com> Date: Sun, 30 Jul 2023 20:25:57 +0100 Subject: [PATCH 5/6] Added style guide for Hafting 2008 and experiments --- documents/style_guide.md | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/documents/style_guide.md b/documents/style_guide.md index d6b08da9..e5d188fc 100644 --- a/documents/style_guide.md +++ b/documents/style_guide.md @@ -485,3 +485,52 @@ The class does not contain its own attributes and only provides functions which > - `biny`: *ndarray (nybins +1,)* > - Description: The bin limits of the ratemap on the y axis (returned as list or tupe depending on the argument type). > - Description: Plot tetrode ratemap from spike data for a given recording index or a list of recording index. If given a list or tuple as argument, all arguments must be list, tuple, or None. +> +> * `plot_trajectory()` +> - Accepts: +> - `recording_index`: *int, tuple of ints, list of ints* +> - Default: `None` +> - Description: The recording index to plot spike ratemap, if list or tuple, it will recursively call this function to make a plot per recording index. If this argument is list or tuple, the rest of variables must be list or tuple with their respective types, or keep the default None value. +> - `save_path`: *str, list of str, tuple of str* +> - Default: `None` +> - Description: The saving path of the generated figure. If None then no figure is saved +> - `ax`: *mpl.axes._subplots.AxesSubplot, list of ax, or tuple of ax* +> - Default: `None` +> - Description: An axis or list of axis from subplot from matplotlib where the ratemap will be plotted. If None, ax is generated with default options. +> - `plot_every`: *int* +> - Default: `20` +> - Description: The number of time steps skipped to make the plot to reduce cluttering. +> - Returns: +> - `x`: *ndarray (n_samples,)* +> - Description: The x position throughout recording of the given session. +> - `y`: *ndarray (n_samples,)* +> - Description: The y position throughout recording of the given session. +> - `time_array`: *ndarray (n_samples,)* +> - Description: An array with the timestamps in seconds per position of the given session. +> - Description: Plot of the animal trajectory from a given recording index, corresponding to a recording session. +> +> * `recording_tetr()` +> - Accepts: +> - `recording_index`: *int, tuple of ints, list of ints* +> - Default: `None` +> - Description: The recording index to plot spike ratemap, if list or tuple, it will recursively call this function to make a plot per recording index. If this argument is list or tuple, the rest of variables must be list or tuple with their respective types, or keep the default None value. +> - `save_path`: *str, list of str, tuple of str* +> - Default: `None` +> - Description: The saving path of the generated figure. If None then no figure is saved +> - `tetrode_id`: *str, list of str, or tuple of str* +> - Default: `None` +> - Description: tetrode id in the corresponding session. +> - `bin_size`: *float* +> - Default: `2.0` +> - Description: The bin size to discretize space when computing ratemap +> - Returns: +> - `h`: *ndarray (nybins, nxbins)* +> - Description: Number of spikes falling on each bin through the recorded session, nybins number of bins in y axis, nxbins number of bins in x axis (returned as list or tupe depending on the argument type). +> - `binx`: *ndarray (nxbins +1,)* +> - Description: The bin limits of the ratemap on the x axis (returned as list or tupe depending on the argument type). +> - `biny`: *ndarray (nybins +1,)* +> - Description: The bin limits of the ratemap on the y axis (returned as list or tupe depending on the argument type). +> - Description: The tetrode ratemap from spike data for a given recording index or a list of recording index. If given a list or tuple as argument, all arguments must be list, tuple, or None. + +The example usage of this class can then be found in the ["experimental_data_examples.ipynb"](https://github.com/SainsburyWellcomeCentre/NeuralPlayground/blob/main/examples/experimental_examples/experimental_data_examples.ipynb) notebook as per the instructions on adding an experimental class. + From 573e0c550cb43369bd1db20babf38c61a9f939da Mon Sep 17 00:00:00 2001 From: Devon Jarvis <30460455+JarvisDevon@users.noreply.github.com> Date: Sun, 30 Jul 2023 20:27:35 +0100 Subject: [PATCH 6/6] Update style_guide.md --- documents/style_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documents/style_guide.md b/documents/style_guide.md index e5d188fc..9c72fe7f 100644 --- a/documents/style_guide.md +++ b/documents/style_guide.md @@ -532,5 +532,5 @@ The class does not contain its own attributes and only provides functions which > - Description: The bin limits of the ratemap on the y axis (returned as list or tupe depending on the argument type). > - Description: The tetrode ratemap from spike data for a given recording index or a list of recording index. If given a list or tuple as argument, all arguments must be list, tuple, or None. -The example usage of this class can then be found in the ["experimental_data_examples.ipynb"](https://github.com/SainsburyWellcomeCentre/NeuralPlayground/blob/main/examples/experimental_examples/experimental_data_examples.ipynb) notebook as per the instructions on adding an experimental class. +The example usage of this class can then be found in the ["experimental_data_examples.ipynb"](https://github.com/SainsburyWellcomeCentre/NeuralPlayground/blob/main/examples/experimental_examples/experimental_data_examples.ipynb) notebook as per the instructions on adding an experimental class.