Skip to content

Commit 33f4997

Browse files
committed
figured out set_locs force_include_bo_locs flag and set the new version to 0.2.0
1 parent 1e580ea commit 33f4997

File tree

10 files changed

+14
-12
lines changed

10 files changed

+14
-12
lines changed
20 Bytes
Binary file not shown.
20 Bytes
Binary file not shown.

docs/auto_examples/debug_predict.ipynb

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/auto_examples/debug_predict.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ This example shows debugging process for predict. Delete before pip push.
263263
noise = 0
264264
265265
# locs
266-
locs = se.simulate_locations(n_elecs=100, random_seed=random_seed)
266+
locs = se.simulate_locations(n_elecs=100, set_random_seed=random_seed)
267267
268268
# create model locs from 75 locations
269269
mo_locs = locs.sample(75, random_state=random_seed).sort_values(['x', 'y', 'z'])
@@ -313,7 +313,7 @@ This example shows debugging process for predict. Delete before pip push.
313313
noise = 0
314314
315315
# locs
316-
locs = se.simulate_locations(n_elecs=100, random_seed=random_seed)
316+
locs = se.simulate_locations(n_elecs=100, set_random_seed=random_seed)
317317
318318
# create model locs from 50 locations
319319
mo_locs = locs.sample(100, random_state=random_seed).sort_values(['x', 'y', 'z'])
@@ -360,7 +360,7 @@ This example shows debugging process for predict. Delete before pip push.
360360
noise = 0
361361
362362
# locs
363-
locs = se.simulate_locations(n_elecs=100, random_seed=random_seed)
363+
locs = se.simulate_locations(n_elecs=100, set_random_seed=random_seed)
364364
365365
# create model locs from 75 locations
366366
mo_locs = locs.sample(75, random_state=random_seed).sort_values(['x', 'y', 'z'])
@@ -413,7 +413,7 @@ This example shows debugging process for predict. Delete before pip push.
413413
noise = 0
414414
415415
# locs
416-
locs = se.simulate_locations(n_elecs=100, random_seed=random_seed)
416+
locs = se.simulate_locations(n_elecs=100, set_random_seed=random_seed)
417417
418418
# create brain locs from 75 locations
419419
bo_locs = locs.sample(75, random_state=random_seed).sort_values(['x', 'y', 'z'])

docs/auto_examples/model_add_subtract.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"execution_count": null,
2525
"cell_type": "code",
2626
"source": [
27-
"# Code source: Lucy Owen & Andrew Heusser\n# License: MIT\nimport supereeg as se\nimport numpy as np\n\n# some example locations\nlocs = np.array([[-61., -77., -3.],\n [-41., -77., -23.],\n [-21., -97., 17.],\n [-21., -37., 77.],\n [-21., 63., -3.],\n [ -1., -37., 37.],\n [ -1., 23., 17.],\n [ 19., -57., -23.],\n [ 19., 23., -3.],\n [ 39., -57., 17.],\n [ 39., 3., 37.],\n [ 59., -17., 17.]])\n\n\n# number of timeseries samples\nn_samples = 10\n# number of subjects\nn_subs = 6\n# number of electrodes\nn_elecs = 5\n# simulate some brain objects\ndata = [se.simulate_model_bos(n_samples=10, sample_rate=10, locs=locs, sample_locs = n_elecs, random_seed=123, noise=0) for x in range(n_subs)]\n# create a model from the first 5 brain objects and another from 1 brain object\nmo1 = se.Model(data=data[0:5], locs=locs, n_subs=5)\nmo2 = se.Model(data=data[5:6], locs=locs, n_subs=1)\n\n# adding the models\nmo3 = mo1 + mo2\n\n# plot the added model\nmo3.plot_data()\n# adding these models is the same as making a model from all 6 brain objects at once\nmo3_alt = se.Model(data=data[0:6], locs=locs, n_subs=6)\n# plot the alternate model\nmo3_alt.plot_data()\n# show that they're the same\nassert np.allclose(mo3.get_model(), mo3_alt.get_model())\n# show that the number of subjects is also added\nassert(mo3.n_subs == mo1.n_subs + mo2.n_subs)\n\n# you can also subtract models\nmo2_sub = mo3 - mo1\n\n# plot the subtracted model\nmo2_sub.plot_data()\n# plot the original\nmo2.plot_data()\n# show that subratracting mo1 from mo3 will equal mo2\nassert np.allclose(mo2.get_model(), mo2_sub.get_model(), equal_nan=True)\n# show that the number of subjects is also subtracted\nassert(mo2_sub.n_subs == mo2.n_subs)\n# subtraction also updates the meta field, changing stable from True to False\nmo2.info()\nmo2_sub.info()\n# now that the new model is not stable, so you can't add anything to it\ntry:\n assert mo2_sub + mo3\nexcept AssertionError:\n assert True == True"
27+
"# Code source: Lucy Owen & Andrew Heusser\n# License: MIT\nimport supereeg as se\nimport numpy as np\n\n# some example locations\nlocs = np.array([[-61., -77., -3.],\n [-41., -77., -23.],\n [-21., -97., 17.],\n [-21., -37., 77.],\n [-21., 63., -3.],\n [ -1., -37., 37.],\n [ -1., 23., 17.],\n [ 19., -57., -23.],\n [ 19., 23., -3.],\n [ 39., -57., 17.],\n [ 39., 3., 37.],\n [ 59., -17., 17.]])\n\n\n# number of timeseries samples\nn_samples = 10\n# number of subjects\nn_subs = 6\n# number of electrodes\nn_elecs = 5\n# simulate some brain objects\ndata = [se.simulate_model_bos(n_samples=10, sample_rate=10, locs=locs, sample_locs = n_elecs, set_random_seed=123, noise=0) for x in range(n_subs)]\n# create a model from the first 5 brain objects and another from 1 brain object\nmo1 = se.Model(data=data[0:5], locs=locs, n_subs=5)\nmo2 = se.Model(data=data[5:6], locs=locs, n_subs=1)\n\n# adding the models\nmo3 = mo1 + mo2\n\n# plot the added model\nmo3.plot_data()\n# adding these models is the same as making a model from all 6 brain objects at once\nmo3_alt = se.Model(data=data[0:6], locs=locs, n_subs=6)\n# plot the alternate model\nmo3_alt.plot_data()\n# show that they're the same\nassert np.allclose(mo3.get_model(), mo3_alt.get_model())\n# show that the number of subjects is also added\nassert(mo3.n_subs == mo1.n_subs + mo2.n_subs)\n\n# you can also subtract models\nmo2_sub = mo3 - mo1\n\n# plot the subtracted model\nmo2_sub.plot_data()\n# plot the original\nmo2.plot_data()\n# show that subratracting mo1 from mo3 will equal mo2\nassert np.allclose(mo2.get_model(), mo2_sub.get_model(), equal_nan=True)\n# show that the number of subjects is also subtracted\nassert(mo2_sub.n_subs == mo2.n_subs)\n# subtraction also updates the meta field, changing stable from True to False\nmo2.info()\nmo2_sub.info()\n# now that the new model is not stable, so you can't add anything to it\ntry:\n assert mo2_sub + mo3\nexcept AssertionError:\n assert True == True"
2828
],
2929
"outputs": [],
3030
"metadata": {

docs/auto_examples/model_add_subtract.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ In this example, we show you how to add and subtract models.
4242
# number of electrodes
4343
n_elecs = 5
4444
# simulate some brain objects
45-
data = [se.simulate_model_bos(n_samples=10, sample_rate=10, locs=locs, sample_locs = n_elecs, random_seed=123, noise=0) for x in range(n_subs)]
45+
data = [se.simulate_model_bos(n_samples=10, sample_rate=10, locs=locs, sample_locs = n_elecs, set_random_seed=123, noise=0) for x in range(n_subs)]
4646
# create a model from the first 5 brain objects and another from 1 brain object
4747
mo1 = se.Model(data=data[0:5], locs=locs, n_subs=5)
4848
mo2 = se.Model(data=data[5:6], locs=locs, n_subs=1)

docs/modules/generated/supereeg.Brain.apply_filter.examples

Whitespace-only changes.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='supereeg',
11-
version='0.1.1',
11+
version='0.2.0',
1212
description=DESCRIPTION,
1313
long_description=' ',
1414
author='Contextual Dynamics Laboratory',

supereeg/load.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ def _load_from_cache(fname, ftype, sample_inds=None, loc_inds=None, field=None):
221221
else:
222222
return Brain(**dd.io.load(fullpath))
223223
elif ftype is 'mo':
224-
#return Model(**dd.io.load(fullpath))
224+
# if the model was created using supereeg<0.2.0, load using the "old" format
225+
# (i.e. supereeg>=0.2.0 computes model in log space)
225226
date_created = _load_field(fullpath, field='date_created')
226227
if datetime.strptime(date_created, "%c")< datetime(2018, 7, 27, 14, 40, 48, 359141):
227228
num = _load_field(fullpath, field='numerator')

supereeg/model.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,11 @@ def set_locs(self, new_locs, force_include_bo_locs=False):
256256
new_locs_in_self = _count_overlapping(self.get_locs(), new_locs)
257257

258258
if np.all(new_locs_in_self):
259-
self.locs = self.locs.iloc[new_locs_in_self, :]
259+
inds = _count_overlapping(new_locs, self.get_locs())
260+
self.locs = self.locs.iloc[inds, :]
260261
self.n_locs = self.locs.shape[0]
261-
self.numerator = self.numerator[new_locs_in_self, :][:, new_locs_in_self]
262-
self.denominator = self.denominator[new_locs_in_self, :][:, new_locs_in_self]
262+
self.numerator = self.numerator[inds, :][:, inds]
263+
self.denominator = self.denominator[inds, :][:, inds]
263264
return
264265
else:
265266
rbf_weights = _log_rbf(new_locs, self.get_locs())

0 commit comments

Comments
 (0)