Please see the pull request: https://github.com/the-virtual-brain/tvb-root/pull/553
in monitors.py file in line 559 when the gain matrix for the MEG monitor is specified (when running region-wise simulation)
the code is:
>>> gain = numpy.zeros((self.gain.shape, conn.number_of_regions))
this causes the gain matrix shape to have shape equal to the number of regions regardless of whether they are cortical or subcortical. The resulting gain matrix has shape:
[number of sources, number of regions]
A few lines later in line 569, when considering subcortical regions (if they are specified in the connectome), they are stacked onto the gain matrix again, causing the matrix to have the shape of:
[number of sources, number of regions + number of subcortical regions]
When running the simulation this causes an error related to the mismatch in the shape of the specified and resulting outputs of the monitor.
I have changed the line 559 to adjust the shape of the gain matrix:
>>> gain = numpy.zeros((self.gain.shape, conn.number_of_regions -len(numpy.where(~conn.cortical))))
and this created correct outputs.
I have tested this on the default 192 regions connectivity. The code still throws RunTimeWarnings pertaining to the divisions by zero - resulting from the fact that distances and sensors positions are sometimes set to 0 (in the input files), but the resulting shape of the projection matrix (gain matrix) and output of test simulations seem to be correct.
- relates to
TVB-3018 Gain Matrix is incorrect for Surface sim with subcortical areas