Skip to content

Commit

Permalink
Merge pull request #198 from scottclowe/api_deltaf-raw-shape
Browse files Browse the repository at this point in the history
API: Change the shape of deltaf_raw to have the same number of dimensions as other outputs
  • Loading branch information
scottclowe committed Jun 29, 2021
2 parents f061d4e + a4633f2 commit 8296a6c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/Basic usage.ipynb
Expand Up @@ -279,7 +279,7 @@
"t = 1\n",
"\n",
"(\n",
" hv.Curve(experiment.deltaf_raw[c][t], label=\"Raw\", vdims=[\"df/f0\"])\n",
" hv.Curve(experiment.deltaf_raw[c][t][0, :], label=\"Raw\", vdims=[\"df/f0\"])\n",
" * hv.Curve(experiment.deltaf_result[c, t][0, :], label=\"Decontaminated\")\n",
")"
]
Expand Down
10 changes: 7 additions & 3 deletions fissa/core.py
Expand Up @@ -395,14 +395,18 @@ class Experiment:
deltaf_raw : :class:`numpy.ndarray`
A :class:`numpy.ndarray` of shape ``(n_rois, n_trials)``, each element
of which is itself a :class:`numpy.ndarray` shaped ``(n_timepoint, )``.
of which is itself a :class:`numpy.ndarray` shaped ``(1, n_timepoint)``.
The amount of change in fluorence relative to the baseline fluorence
(Δf/f\ :sub:`0`).
This field is only populated after :meth:`calc_deltaf` has been run;
until then, it is set to ``None``.
.. versionchanged:: 1.0.0
The shape of the interior arrays changed from ``(n_timepoint, )``
to ``(1, n_timepoint)``.
deltaf_result : :class:`numpy.ndarray`
A :class:`numpy.ndarray` of shape ``(n_rois, n_trials)``, each element
of which is itself a :class:`numpy.ndarray` shaped
Expand Down Expand Up @@ -964,7 +968,7 @@ def calc_deltaf(self, freq, use_raw_f0=True, across_trials=True):
for trial in range(self.nTrials):
nextTrial = curTrial + self.raw[cell][trial].shape[1]
signal = raw_conc[curTrial:nextTrial]
deltaf_raw[cell][trial] = signal
deltaf_raw[cell][trial] = np.expand_dims(signal, axis=0)
signal = result_conc[:, curTrial:nextTrial]
deltaf_result[cell][trial] = signal
curTrial = nextTrial
Expand All @@ -986,7 +990,7 @@ def calc_deltaf(self, freq, use_raw_f0=True, across_trials=True):
result_sig = (result_sig - result_f0) / result_f0

# store deltaf/f0s
deltaf_raw[cell][trial] = raw_sig
deltaf_raw[cell][trial] = np.expand_dims(raw_sig, axis=0)
deltaf_result[cell][trial] = result_sig

self.deltaf_raw = deltaf_raw
Expand Down
Binary file modified fissa/tests/resources/b/expected_py2.npz
Binary file not shown.
Binary file modified fissa/tests/resources/b/expected_py3.npz
Binary file not shown.
6 changes: 1 addition & 5 deletions fissa/tests/test_core.py
Expand Up @@ -178,12 +178,8 @@ def compare_matlab(self, fname, experiment, compare_deltaf=None):
M["df_result"][0, 0][0][0, 0][0],
experiment.deltaf_result[0, 0],
)
# Row and column vectors on MATLAB are 2d instead of 1d, and df_raw
# is a vector, not a matrix, so has an extra dimension.
# N.B. This extra dimension is in the wrong place as it doesn't align
# with the other attributes.
self.assert_allclose(
M["df_raw"][0, 0][0][0, 0][0][0, :],
M["df_raw"][0, 0][0][0, 0][0],
experiment.deltaf_raw[0, 0],
)

Expand Down

0 comments on commit 8296a6c

Please sign in to comment.