Skip to content

Conversation

@larsoner
Copy link
Member

@larsoner larsoner commented Jun 22, 2020

Arguably part of #4859, originally brought up in #5745, resurfaced on the mailing list today.

Closes #7915

@mmagnuski you might have asked about this sort of thing before, interested in reviewing and/or trying?

In theory at some point we could probably exploit a lattice structure to avoid a lot of unnecessary checks (just like we do in the *_temporal variants of our stats functions), but this is at least a good start that should allow people to do these sorts of analyses even if they are slower than they could be.

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

code looks reasonable. Just the two comments.

@mmagnuski
Copy link
Member

@larsoner Great, I'll take a look within 24h!

if p_val <= 0.05:
T_obs_plot[c] = T_obs[c]

# Just plot one channel's data
Copy link
Member

Choose a reason for hiding this comment

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

I'd write that we find indices of the maximum absolute t value

epochs_power = tfr_epochs.data

###############################################################################
# Define connectivity for statistics
Copy link
Member

Choose a reason for hiding this comment

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

I must say that the naming for adjacency is a bit unfortunate in mne. I was a few times in a situation when I had to search online for mne function that finds adjacency. Because it has connectivity in its name finding it was a bit difficult: I was getting lots of results related to actual connectivity (coherence, phase slope index etc.) but not the function I needed.

@larsoner
Copy link
Member Author

We could rename to adjacency in another PR. I agree it's bad naming to have this collide with functional and effective connectivity, I almost named this combine_adjacency but the deprecation bothered me.

@agramfort okay to rename via deprecation spatio_src_connectivity and related functions to spatial_src_adjacency, and clustering arguments to adjacency instead of connectivity?

@agramfort
Copy link
Member

agramfort commented Jun 23, 2020 via email

@larsoner
Copy link
Member Author

Based on a minimal-effort searching (others feel free to chime in if you know of others or better for these packages)

  • FieldTrip appears to use neighbours but in the narrative doc also mentions "connected" subsets and "adjacency"

  • Brainstorm uses fieldtrip (?) but only uses the term "adjacency" in the couple of places I looked

  • Maris and Oostenveld:

    ... Cluster the selected samples in connected sets on the basis of temporal adjacency... instead of clustering selected (sensor, time)-samples in connected sets on the basis of spatial and temporal adjacency, we now cluster the selected (frequency, time)-samples on the basis of spectral and temporal adjacency

To me "adjacency" is the winner based on this

@agramfort
Copy link
Member

agramfort commented Jun 24, 2020 via email

@larsoner
Copy link
Member Author

Okay, deprecations complete for connectivity->adjacency. Instead of +182/−15 you now get +714/−468 @agramfort :)

# for now
assert np.in1d(conn, [0, 1, 2, 3]).all()
assert conn.shape == conn_sk.shape
assert_array_equal(conn, conn)
Copy link
Member

Choose a reason for hiding this comment

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

both arrays are the same object here

@mmagnuski
Copy link
Member

Looks good! And I'm glad it's adjacency now! :) (just one small comment regarding one of the tests)

@larsoner
Copy link
Member Author

Good catch @mmagnuski, that errant naming was missing an issue with the diagonals being repeated such that they were no longer unity values (they were equal to len(structure) instead of always being 1.).

@larsoner larsoner merged commit d122dca into mne-tools:master Jun 25, 2020
@larsoner larsoner deleted the conn branch June 25, 2020 17:12
larsoner added a commit to larsoner/mne-python that referenced this pull request Jun 25, 2020
* upstream/master:
  MRG: Prepare migration to PyVista 0.25 (mne-tools#7791)
  MAINT: Simpler VTK [circle front] (mne-tools#7931)
  MRG, ENH: Add arbitrary connectivity for stats (mne-tools#7916)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cluster-based Permutation test for Time-Frequency Data - 3D clusters

4 participants