diff --git a/CHANGELOG.md b/CHANGELOG.md index 678769de..0faa0a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ # Change Log All notable changes to this project will be documented in this file. +## [1.0.1] = 2020-07-22 + +- Added sweep_numbers as a property of EphysDataSet + ## [1.0.0] = 2020-06-30 1.0.0 is the first public release of IPFX. As of this version: -- IPFX is now [on pypi](https://pypi.org/project/IPFX/)! You can install +- IPFX is now [on pypi](https://pypi.org/project/IPFX/)! You can install - IPFX now supports [NeurodataWithoutBorders](https://www.nwb.org) version 2 in place of version 1. - IPFX supports Python 3 in place of Python 2. -- numerous features, [documentation](https://ipfx.readthedocs.io/en/latest/) updates, and bugfixes have been incorporated into IPFX. \ No newline at end of file +- numerous features, [documentation](https://ipfx.readthedocs.io/en/latest/) updates, and bugfixes have been incorporated into IPFX. diff --git a/ipfx/dataset/ephys_data_set.py b/ipfx/dataset/ephys_data_set.py index e49fcf79..6e6634b5 100644 --- a/ipfx/dataset/ephys_data_set.py +++ b/ipfx/dataset/ephys_data_set.py @@ -43,15 +43,15 @@ class EphysDataSet(object): @property def ontology(self) -> StimulusOntology: - """The stimulus ontology maps codified description of the stimulus type + """The stimulus ontology maps codified description of the stimulus type to the human-readable descriptions. """ return self._data.ontology @property def sweep_table(self) -> pd.DataFrame: - """Each row of the sweep table contains the metadata for a single - sweep. In particular details of the stimulus presented and the clamp + """Each row of the sweep table contains the metadata for a single + sweep. In particular details of the stimulus presented and the clamp mode. See EphysDataInterface.get_sweep_metadata for more information. """ @@ -82,30 +82,42 @@ def sweep_info(self, value): self._sweep_info[sweep["sweep_number"]] = sweep else: self._sweep_info = value - + if hasattr(self, "_sweep_table"): del self._sweep_table + @property + def sweep_numbers(self): + """ Returns array containing all sweep numbers in this data set. + + Returns + ------- + sweep_numbers : numpy.ndarray + Array containing all the sweep numbers + + """ + return self._data.sweep_numbers + def __init__( self, data: EphysDataInterface, sweep_info: Optional[List[Dict]] = None ): - """EphysDataSet is the preferred interface for running analyses or + """EphysDataSet is the preferred interface for running analyses or pipeline code. Parameters ---------- - data : This object must implement the EphysDataInterface. It will - handle any loading of data from external sources (such as NWB2 + data : This object must implement the EphysDataInterface. It will + handle any loading of data from external sources (such as NWB2 files) """ self._data: EphysDataInterface = data self.sweep_info = sweep_info or [] def _setup_stimulus_repeat_lookup(self): - """Each sweep contains the ith repetition of some stimulus (from 1 -> - the number of times that stimulus was presented). Find i for each + """Each sweep contains the ith repetition of some stimulus (from 1 -> + the number of times that stimulus was presented). Find i for each sweep. Notes @@ -148,16 +160,16 @@ def filtered_sweep_table( if stimuli: mask = st[self.STIMULUS_CODE].apply( - self.ontology.stimulus_has_any_tags, - args=(stimuli,), + self.ontology.stimulus_has_any_tags, + args=(stimuli,), tag_type="code" ) st = st[mask.astype(bool)] if stimuli_exclude: mask = ~st[self.STIMULUS_CODE].apply( - self.ontology.stimulus_has_any_tags, - args=(stimuli_exclude,), + self.ontology.stimulus_has_any_tags, + args=(stimuli_exclude,), tag_type="code" ) st = st[mask.astype(bool)] @@ -198,7 +210,7 @@ def get_sweep_number( stimuli: Collection[str], clamp_mode: Optional[str] = None ) -> int: - """Convenience for getting the integer identifier of the temporally + """Convenience for getting the integer identifier of the temporally latest sweep matching argued criteria. Parameters @@ -214,7 +226,7 @@ def get_sweep_number( def sweep(self, sweep_number: int) -> Sweep: """ - Create an instance of the Sweep class with the data loaded from the + Create an instance of the Sweep class with the data loaded from the from a file Parameters @@ -235,8 +247,8 @@ def sweep(self, sweep_number: int) -> Sweep: voltage, current = type(self)._voltage_current( sweep_data["stimulus"], - sweep_data["response"], - sweep_metadata["clamp_mode"], + sweep_data["response"], + sweep_metadata["clamp_mode"], enforce_equal_length=True, ) @@ -258,15 +270,15 @@ def sweep(self, sweep_number: int) -> Sweep: return sweep def sweep_set( - self, + self, sweep_numbers: Union[Sequence[int], int, None] = None ) -> SweepSet: - """Construct a SweepSet object, which offers convenient access to an + """Construct a SweepSet object, which offers convenient access to an ordered collection of sweeps. Parameters ---------- - sweep_numbers : Identifiers for the sweeps which will make up this set. + sweep_numbers : Identifiers for the sweeps which will make up this set. If None, use all available sweeps. Returns @@ -328,12 +340,12 @@ def get_sweep_data(self, sweep_number: int) -> Dict: return sweep_data def get_clamp_mode(self, sweep_number: int) -> str: - """Obtain the clamp mode of a given sweep. Should be one of + """Obtain the clamp mode of a given sweep. Should be one of EphysDataSet.VOLTAGE_CLAMP or EphysDataSet.CURRENT_CLAMP Parameters ---------- - sweep_number : identifier for the sweep whose clamp mode will be + sweep_number : identifier for the sweep whose clamp mode will be returned Returns @@ -347,7 +359,7 @@ def get_stimulus_code(self, sweep_number: int) -> str: Parameters ---------- - sweep_number : identifier for the sweep whose stimulus code will be + sweep_number : identifier for the sweep whose stimulus code will be returned Returns @@ -357,14 +369,14 @@ def get_stimulus_code(self, sweep_number: int) -> str: return self._data.get_stimulus_code(sweep_number) def get_stimulus_code_ext(self, sweep_number: int) -> str: - """Obtain the extended stimulus code for a sweep. This is the stimulus - code for that sweep augmented with an integer counter describing the - number of presentations of that stimulus up to and including the + """Obtain the extended stimulus code for a sweep. This is the stimulus + code for that sweep augmented with an integer counter describing the + number of presentations of that stimulus up to and including the requested sweep. Parameters ---------- - sweep_number : identifies the sweep whose extended stimulus code will + sweep_number : identifies the sweep whose extended stimulus code will be returned Returns @@ -383,7 +395,7 @@ def get_stimulus_units(self, sweep_number: int) -> str: Parameters ---------- - sweep_number : identifies the sweep whose stimulus unit will be + sweep_number : identifies the sweep whose stimulus unit will be returned Returns @@ -396,11 +408,11 @@ def get_stimulus_units(self, sweep_number: int) -> str: def _voltage_current( cls, stimulus: np.ndarray, - response: np.ndarray, + response: np.ndarray, clamp_mode: str, enforce_equal_length: bool = True ) -> Tuple[np.array, np.array]: - """Resolve the stimulus and response arrays from a sweep's data into + """Resolve the stimulus and response arrays from a sweep's data into voltage and current, using the clamp mode as a guide Parameters @@ -408,14 +420,14 @@ def _voltage_current( stimulus : stimulus trace response : response trace clamp_mode : Used to map stimulus and response to voltage and current - enforce_equal_length : Raise a ValueError if the stimulus and + enforce_equal_length : Raise a ValueError if the stimulus and response arrays have uneven numbers of samples Returns ------- The voltage and current traces. - """ + """ if clamp_mode == cls.VOLTAGE_CLAMP: voltage = stimulus diff --git a/ipfx/version.txt b/ipfx/version.txt index afaf360d..7dea76ed 100644 --- a/ipfx/version.txt +++ b/ipfx/version.txt @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.0.1