Skip to content

BUG: empty patches are not handled properly #69

@ctrltz

Description

@ctrltz

Empty patches lead to an error when combining sources into stc, and the error message is not very descriptive.

 40%|███▉      | 99/250 [2:56:36<4:33:43, 108.76s/it]/data/p_02490/Scripts/meegsim/src/meegsim/sources.py:245: RuntimeWarning: divide by zero encountered in scalar divide
  scaling_factor = 1 / np.sqrt(len(self.vertno))

 40%|███▉      | 99/250 [2:56:47<4:29:39, 107.15s/it]
Traceback (most recent call last):
  File "/data/p_02490/Scripts/roiextract_simulations/scripts/entry_points/simulate.py", line 280, in <module>
    simulate(
  File "/data/p_02490/Scripts/roiextract_simulations/scripts/entry_points/simulate.py", line 205, in simulate
    sc = sim.simulate(
         ^^^^^^^^^^^^^
  File "/data/p_02490/Scripts/meegsim/src/meegsim/simulate.py", line 446, in simulate
    sources, noise_sources = _simulate(
                             ^^^^^^^^^^
  File "/data/p_02490/Scripts/meegsim/src/meegsim/simulate.py", line 513, in _simulate
    _adjust_snr_global(
  File "/data/p_02490/Scripts/meegsim/src/meegsim/snr.py", line 163, in _adjust_snr_global
    stc_signal = _combine_sources_into_stc(sources.values(), src, tstep)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/p_02490/Scripts/meegsim/src/meegsim/sources.py", line 370, in _combine_sources_into_stc
    vertices_stacked = np.vstack(vertices)
                       ^^^^^^^^^^^^^^^^^^^
  File "/data/u_kapralov_software/miniconda3/envs/roiextract_simulations/lib/python3.12/site-packages/numpy/core/shape_base.py", line 289, in vstack
    return _nx.concatenate(arrs, 0, dtype=dtype, casting=casting)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 2 and the array at index 52 has size 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions