emiraran commited on
Commit
ff45deb
·
verified ·
1 Parent(s): 4a1d585

Pure biophysical homeostatic baseline adaptation: remove 1.0 saturation

Browse files
Files changed (1) hide show
  1. src/connectome_engine.py +19 -14
src/connectome_engine.py CHANGED
@@ -63,40 +63,45 @@ class ConnectomeEngine:
63
  self._calibrate_resting_baselines()
64
 
65
  def _build_circuit_indices(self):
66
- """Pre-indexes neuron subgroups for rapid population readout."""
67
  meta = self.meta
68
- cell_types = meta["cell_type"].fillna("unknown").str.lower().values
 
 
 
69
 
70
  # Optic Lobe (Visual System)
71
- optic_mask = meta["super_class"].str.lower().isin(["optic", "visual_projection", "visual_centrifugal"]).values
72
  self.optic_mask = optic_mask
73
 
74
- # Hemispheric split by center-line (X coordinate ~ 550,000 nm in FlyWire coordinates)
75
  x_coords = self.coords[:, 0]
76
- midline_x = 550000.0
 
 
77
 
78
- self.optic_left_indices = np.where(optic_mask & (x_coords < midline_x))[0]
79
- self.optic_right_indices = np.where(optic_mask & (x_coords >= midline_x))[0]
80
 
81
  # Central Complex (Navigation & Steering Compass)
82
- cx_mask = meta["cell_class"].fillna("").str.lower().isin(["central_complex", "cx"]) | meta["super_class"].str.lower().isin(["central"])
83
  self.cx_indices = np.where(cx_mask)[0]
84
  if len(self.cx_indices) == 0:
85
- self.cx_indices = np.where(np.char.find(cell_types, "epg") >= 0)[0]
86
 
87
  # Mushroom Body Kenyon Cells (Olfactory & Threat Memory)
88
- kc_mask = np.char.find(cell_types, "kc") >= 0
89
  self.kc_indices = np.where(kc_mask)[0]
90
 
91
  # Motion Vision Columnar Neurons (T4 / T5 optical flow detectors)
92
- t4t5_mask = (np.char.find(cell_types, "t4") >= 0) | (np.char.find(cell_types, "t5") >= 0)
93
  self.t4t5_indices = np.where(t4t5_mask)[0]
94
 
95
  # Descending Motor Neurons (Premotor steering & attack drivers)
96
- dn_mask = meta["super_class"].str.lower().isin(["descending"])
97
  self.dn_all_indices = np.where(dn_mask)[0]
98
- self.dn_left_indices = np.where(dn_mask & (x_coords < midline_x))[0]
99
- self.dn_right_indices = np.where(dn_mask & (x_coords >= midline_x))[0]
100
 
101
  # Convert to device tensors for zero-copy slicing
102
  self.t_optic_left = torch.from_numpy(self.optic_left_indices).to(self.device)
 
63
  self._calibrate_resting_baselines()
64
 
65
  def _build_circuit_indices(self):
66
+ """Pre-indexes neuron subgroups for rapid population readout (100% NumPy 1.x & 2.x compatible)."""
67
  meta = self.meta
68
+ ct = meta["cell_type"].fillna("unknown").astype(str).str.lower()
69
+ sc = meta["super_class"].fillna("unknown").astype(str).str.lower()
70
+ cc = meta["cell_class"].fillna("unknown").astype(str).str.lower()
71
+ side = meta["side"].fillna("unknown").astype(str).str.lower()
72
 
73
  # Optic Lobe (Visual System)
74
+ optic_mask = sc.isin(["optic", "visual_projection", "visual_centrifugal"]).values
75
  self.optic_mask = optic_mask
76
 
77
+ # Hemispheric split by biological side annotation and midline coordinate (~130,000 nm)
78
  x_coords = self.coords[:, 0]
79
+ midline_x = 130000.0
80
+ is_left = (side == "left").values | ((side != "right") & (x_coords < midline_x))
81
+ is_right = (side == "right").values | ((side != "left") & (x_coords >= midline_x))
82
 
83
+ self.optic_left_indices = np.where(optic_mask & is_left)[0]
84
+ self.optic_right_indices = np.where(optic_mask & is_right)[0]
85
 
86
  # Central Complex (Navigation & Steering Compass)
87
+ cx_mask = cc.isin(["central_complex", "cx"]) | sc.isin(["central"])
88
  self.cx_indices = np.where(cx_mask)[0]
89
  if len(self.cx_indices) == 0:
90
+ self.cx_indices = np.where(ct.str.contains("epg", regex=False).values)[0]
91
 
92
  # Mushroom Body Kenyon Cells (Olfactory & Threat Memory)
93
+ kc_mask = ct.str.contains("kc", regex=False).values
94
  self.kc_indices = np.where(kc_mask)[0]
95
 
96
  # Motion Vision Columnar Neurons (T4 / T5 optical flow detectors)
97
+ t4t5_mask = (ct.str.contains("t4", regex=False) | ct.str.contains("t5", regex=False)).values
98
  self.t4t5_indices = np.where(t4t5_mask)[0]
99
 
100
  # Descending Motor Neurons (Premotor steering & attack drivers)
101
+ dn_mask = sc.isin(["descending"]).values
102
  self.dn_all_indices = np.where(dn_mask)[0]
103
+ self.dn_left_indices = np.where(dn_mask & is_left)[0]
104
+ self.dn_right_indices = np.where(dn_mask & is_right)[0]
105
 
106
  # Convert to device tensors for zero-copy slicing
107
  self.t_optic_left = torch.from_numpy(self.optic_left_indices).to(self.device)