Skip to content

Commit 7293f56

Browse files
authored
Merge pull request #616 from int-brain-lab/swanson_split
Swanson split
2 parents 8ed3f53 + 02f630c commit 7293f56

File tree

4 files changed

+23
-29
lines changed

4 files changed

+23
-29
lines changed

ibllib/atlas/flatmaps.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,16 @@ def swanson(filename="swanson2allen.npz"):
137137

138138
def swanson_json(filename="swansonpaths.json"):
139139

140-
OLD_MD5 = ['f848783954883c606ca390ceda9e37d2']
140+
OLD_MD5 = ['97ccca2b675b28ba9b15ca8af5ba4111', # errored map with FOTU and CUL4, 5 mixed up
141+
'56daa7022b5e03080d8623814cda6f38', # old md5 of swanson json without CENT and PTLp
142+
# and CUL4 split (on s3 called swansonpaths_56daa.json)
143+
'f848783954883c606ca390ceda9e37d2']
141144

142145
json_file = AllenAtlas._get_cache_dir().joinpath(filename)
143146
if not json_file.exists() or md5(json_file) in OLD_MD5:
144147
json_file.parent.mkdir(exist_ok=True, parents=True)
145148
_logger.info(f'downloading swanson paths from {aws.S3_BUCKET_IBL} s3 bucket...')
146-
aws.s3_download_file(f'atlas/{json_file.name}', json_file)
149+
aws.s3_download_file(f'atlas/{json_file.name}', json_file, overwrite=True)
147150

148151
with open(json_file) as f:
149152
sw_json = json.load(f)
@@ -198,44 +201,45 @@ def plot_swanson_vector(acronyms=None, values=None, ax=None, hemisphere=None, br
198201
color = empty_color
199202

200203
coords = reg['coordsReg']
204+
reg_id = reg['thisID']
201205

202206
if reg['hole']:
203207
vertices, codes = coords_for_poly_hole(coords)
204208
if orientation == 'portrait':
205209
vertices[:, [0, 1]] = vertices[:, [1, 0]]
206-
plot_polygon_with_hole(ax, vertices, codes, color, **kwargs)
210+
plot_polygon_with_hole(ax, vertices, codes, color, reg_id, **kwargs)
207211
if hemisphere is not None:
208212
color_inv = color if hemisphere == 'mirror' else empty_color
209213
vertices_inv = np.copy(vertices)
210214
vertices_inv[:, 0] = -1 * vertices_inv[:, 0] + (sw.shape[0] * 2)
211-
plot_polygon_with_hole(ax, vertices_inv, codes, color_inv, **kwargs)
215+
plot_polygon_with_hole(ax, vertices_inv, codes, color_inv, reg_id, **kwargs)
212216
else:
213-
plot_polygon_with_hole(ax, vertices, codes, color, **kwargs)
217+
plot_polygon_with_hole(ax, vertices, codes, color, reg_id, **kwargs)
214218
if hemisphere is not None:
215219
color_inv = color if hemisphere == 'mirror' else empty_color
216220
vertices_inv = np.copy(vertices)
217221
vertices_inv[:, 1] = -1 * vertices_inv[:, 1] + (sw.shape[0] * 2)
218-
plot_polygon_with_hole(ax, vertices_inv, codes, color_inv, **kwargs)
222+
plot_polygon_with_hole(ax, vertices_inv, codes, color_inv, reg_id, **kwargs)
219223
else:
220224
coords = [coords] if type(coords) == dict else coords
221225
for c in coords:
222226

223227
if orientation == 'portrait':
224228
xy = np.c_[c['y'], c['x']]
225-
plot_polygon(ax, xy, color, **kwargs)
229+
plot_polygon(ax, xy, color, reg_id, **kwargs)
226230
if hemisphere is not None:
227231
color_inv = color if hemisphere == 'mirror' else empty_color
228232
xy_inv = np.copy(xy)
229233
xy_inv[:, 0] = -1 * xy_inv[:, 0] + (sw.shape[0] * 2)
230-
plot_polygon(ax, xy_inv, color_inv, **kwargs)
234+
plot_polygon(ax, xy_inv, color_inv, reg_id, **kwargs)
231235
else:
232236
xy = np.c_[c['x'], c['y']]
233-
plot_polygon(ax, xy, color, **kwargs)
237+
plot_polygon(ax, xy, color, reg_id, **kwargs)
234238
if hemisphere is not None:
235239
color_inv = color if hemisphere == 'mirror' else empty_color
236240
xy_inv = np.copy(xy)
237241
xy_inv[:, 1] = -1 * xy_inv[:, 1] + (sw.shape[0] * 2)
238-
plot_polygon(ax, xy_inv, color_inv, **kwargs)
242+
plot_polygon(ax, xy_inv, color_inv, reg_id, **kwargs)
239243

240244
if orientation == 'portrait':
241245
ax.set_ylim(0, sw.shape[1])

ibllib/atlas/plots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ def get_bc_10():
3939
return bc
4040

4141

42-
def plot_polygon(ax, xy, color, edgecolor='k', linewidth=0.3, alpha=1):
43-
p = Polygon(xy, facecolor=color, edgecolor=edgecolor, linewidth=linewidth, alpha=alpha)
42+
def plot_polygon(ax, xy, color, reg_id, edgecolor='k', linewidth=0.3, alpha=1):
43+
p = Polygon(xy, facecolor=color, edgecolor=edgecolor, linewidth=linewidth, alpha=alpha, gid=f'region_{reg_id}')
4444
ax.add_patch(p)
4545

4646

47-
def plot_polygon_with_hole(ax, vertices, codes, color, edgecolor='k', linewidth=0.3, alpha=1):
47+
def plot_polygon_with_hole(ax, vertices, codes, color, reg_id, edgecolor='k', linewidth=0.3, alpha=1):
4848
path = mpath.Path(vertices, codes)
49-
patch = PathPatch(path, facecolor=color, edgecolor=edgecolor, linewidth=linewidth, alpha=alpha)
49+
patch = PathPatch(path, facecolor=color, edgecolor=edgecolor, linewidth=linewidth, alpha=alpha, gid=f'region_{reg_id}')
5050
ax.add_patch(patch)
5151

5252

ibllib/oneibl/data_handlers.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import pandas as pd
3-
import numpy as np
43
from pathlib import Path
54
import shutil
65
import os
@@ -11,7 +10,6 @@
1110
from one.webclient import AlyxClient
1211
from one.util import filter_datasets
1312
from one.alf.files import add_uuid_string, session_path_parts
14-
from iblutil.io.parquet import np2str
1513
from ibllib.oneibl.registration import register_dataset, get_lab, get_local_data_repository
1614
from ibllib.oneibl.patcher import FTPPatcher, SDSCPatcher, SDSC_ROOT_PATH, SDSC_PATCH_PATH
1715

@@ -168,12 +166,7 @@ def setUp(self):
168166
sess_path = Path(rel_sess_path).joinpath(d['rel_path'])
169167
full_local_path = Path(self.globus.endpoints['local']['root_path']).joinpath(sess_path)
170168
if not full_local_path.exists():
171-
172-
if one._index_type() is int:
173-
uuid = np2str(np.r_[i[0], i[1]])
174-
elif one._index_type() is str:
175-
uuid = i
176-
169+
uuid = i
177170
self.local_paths.append(full_local_path)
178171
target_paths.append(sess_path)
179172
source_paths.append(add_uuid_string(sess_path, uuid))
@@ -382,12 +375,7 @@ def setUp(self):
382375
SDSC_TMP = Path(SDSC_PATCH_PATH.joinpath(self.task.__class__.__name__))
383376
for i, d in df.iterrows():
384377
file_path = Path(d['session_path']).joinpath(d['rel_path'])
385-
386-
if self.one._index_type() is int:
387-
uuid = np2str(np.r_[i[0], i[1]])
388-
elif self.one._index_type() is str:
389-
uuid = i
390-
378+
uuid = i
391379
file_uuid = add_uuid_string(file_path, uuid)
392380
file_link = SDSC_TMP.joinpath(file_path)
393381
file_link.parent.mkdir(exist_ok=True, parents=True)

ibllib/pipes/training_status.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import seaborn as sns
2020

2121

22-
TRAINING_STATUS = {'not_computed': (-2, (0, 0, 0, 0)),
22+
TRAINING_STATUS = {'untrainable': (-4, (0, 0, 0, 0)),
23+
'unbiasable': (-3, (0, 0, 0, 0)),
24+
'not_computed': (-2, (0, 0, 0, 0)),
2325
'habituation': (-1, (0, 0, 0, 0)),
2426
'in training': (0, (0, 0, 0, 0)),
2527
'trained 1a': (1, (195, 90, 80, 255)),

0 commit comments

Comments
 (0)