Skip to content

Conversation

@morales-gregorio
Copy link
Contributor

Hey!

I finally managed to create the PR for issue #830

Please have a look if you think something is wrong or should be improved.

Best,
Aitor

@pep8speaks
Copy link

pep8speaks commented Aug 26, 2020

Hello @morales-gregorio! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 56:18: E126 continuation line over-indented for hanging indent
Line 61:18: E126 continuation line over-indented for hanging indent

Comment last updated at 2020-08-26 11:16:05 UTC

@samuelgarcia samuelgarcia added this to the 0.9.0 milestone Aug 28, 2020
if not anasiglist[0].t_start == anasig.t_start:
raise ValueError('t_start must be the same for all signals')
if axis == 0:
if not anasiglist[0].magnitude.shape[1] == \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of channels is represented by the last dimension, so better check anasiglist[0].magnitude.shape[-1] here and below

if axis == 0:
if not anasiglist[0].magnitude.shape[1] == \
anasig.magnitude.shape[1]:
raise ValueError('Analogsignals appear to contain different '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...then you can also remove the appear here.

anasig.magnitude.shape[1]:
raise ValueError('Analogsignals appear to contain different '
'number of channels!')
if axis == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should accordingly check all other dimensions except for the first one as in principle there could be more than 2.

@JuliaSprenger
Copy link
Member

I think there's some common features to PR #836 and this one. I will have a look, maybe we can unify the functionality somehow.

assert_same_annotations)

from neo.utils import (get_events, get_epochs, add_epoch, match_events, cut_block_by_epochs)
from neo.utils import (get_events, get_epochs, add_epoch, match_events,
Copy link
Member

@JuliaSprenger JuliaSprenger Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is needed since Neo allows for up to 99 characters per line, see

max-line-length: 99 # Default is 79 in PEP8

Maybe you are using the default PEP8 settings for autoformatting here?

list of analogsignals that will be merged
axis: int
axis along which to perform the merging
`axis = 1` corresponds to stacking the analogsignals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By implementing the combination of signals along two different axis you are covering two different scenarios, that require different checks on the neo level. Eg. when stacking signals (ie merging multiple channels in one Analogsignal) it is useful to ensure they have the same length and cover the same time range. However for concatenating analogsignals along time, these conditions do not need to be fulfilled. I would argue therefore these different cases should also be implemented in separate functions. This would also make it easier for the users to decide which of the actions they actually want to use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another feature that needs to be treated differently depending on the axis are the array_annotations. I am not sure in how far this implementation is taking care of this, but I think we should double check here.

if axis == 1:
if not anasiglist[0].magnitude.shape[0] == \
anasig.magnitude.shape[0]:
raise ValueError('Cannot merge signals of different length.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A reoccurring scenario is that some data can only be loaded into neo with try_signal_grouping=False because of a single sampling point missing in some of the signals. In this case it would be useful to have a force_merge option which ignores the different lengths and cuts the signals to the shortest signal length.

Comment on lines +72 to +75
for anasig in anasiglist:
anasig0.array_annotations = anasig0._merge_array_annotations(anasig)

array_annot = anasig0.array_annotations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that there is a distinction missing whether the analogsignals are concatenated or stacked, which would require different handling of the array annotations.
I guess the protocol should be something like:

  • concatenating: keeping only array_annotations and annotations that are present and equal in all analogsignals in the list, while omitting (?) the rest.
  • stacking: stacking the array_annotatations; keeping only the annotations that are present and equal in all analogsignals; annotations that are different for the analogsignal should then be used as array_annotations instead.

or what do you think is a good merging strategy?

@JuliaSprenger
Copy link
Member

Hi @morales-gregorio,
I improved the performance of concatenating Analogsignals in the proposed concatenate function at #836. This at least covers the aspect of concatenation of AnalogSignals across time, that is also implemented in this PR. Could you check out the performance of #836 and see if this suits your needs?

@apdavison
Copy link
Member

The performance issues that motivated this PR should have been addressed in #836. Please re-open, or create a new issue, if the performance issues remain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants