Skip to content

Commit

Permalink
Added honorStayInside option to init
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjorthmedh committed Oct 25, 2023
1 parent e41fc8b commit 6512ef2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
2 changes: 2 additions & 0 deletions snudda/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def snudda_cli():
action="store_true")
init_parser.add_argument("-connectionFile", "--connectionFile", default=None, dest="connection_file",
help="Use connectivity from user specified JSON file")
init_parser.add_argument("--honorStayInside", "--stayInside", default=False, dest="stay_inside", action="store_true")
init_parser.add_argument("-randomseed", "--randomseed", "--seed", default=None, help="Random seed", type=int)
init_parser.add_argument("--profile", help="Run python cProfile", action="store_true")
init_parser.add_argument("--verbose", action="store_true")
Expand All @@ -55,6 +56,7 @@ def snudda_cli():
place_parser.add_argument("-randomseed", "--randomseed", "--seed", default=None, help="Random seed", type=int)
place_parser.add_argument("--raytraceBorders", help="Ray traces for more precise mesh edge detection",
action="store_true", dest="raytrace_borders", default=False)
place_parser.add_argument("--honorStayInside", dest="stay_inside", default=False)
place_parser.add_argument("--profile", help="Run python cProfile", action="store_true")
place_parser.add_argument("--verbose", action="store_true")
place_parser.add_argument("--h5legacy", help="Use legacy hdf5 support", action="store_true")
Expand Down
14 changes: 10 additions & 4 deletions snudda/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ def init_config_wrapper(self, args):
neurons_dir=args.neurons_dir,
connection_file=args.connection_file,
overwrite=args.overwrite,
random_seed=args.randomseed)
random_seed=args.randomseed,
honor_stay_inside=args.stay_inside)

def init_config(self, network_size,
snudda_data=None,
neurons_dir=None,
connection_file=None,
honor_stay_inside=True, # currently the cli.py defaults to sending False
overwrite=False,
random_seed=None):

Expand Down Expand Up @@ -144,6 +146,7 @@ def init_config(self, network_size,
neurons_dir=neurons_dir,
snudda_data=snudda_data,
config_file=config_file,
honor_stay_inside=honor_stay_inside,
random_seed=random_seed,
connection_override_file=connection_file)

Expand Down Expand Up @@ -175,15 +178,17 @@ def place_neurons_wrapper(self, args):
ipython_profile=args.ipython_profile,
raytrace_borders=args.raytrace_borders,
h5libver=h5libver,
verbose=args.verbose)
verbose=args.verbose,
honor_stay_inside=args.stay_inside)

def place_neurons(self,
random_seed=None,
parallel=False,
ipython_profile=None,
raytrace_borders=False,
h5libver="latest",
verbose=False):
verbose=False,
honor_stay_inside=False):

# self.networkPath = args.path
print("Placing neurons")
Expand All @@ -204,7 +209,8 @@ def place_neurons(self,
d_view=self.d_view,
h5libver=h5libver,
raytrace_borders=raytrace_borders,
random_seed=random_seed)
random_seed=random_seed,
morphologies_stay_inside=honor_stay_inside)

sp.place()

Expand Down
12 changes: 9 additions & 3 deletions snudda/init/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import os.path
import sys
import inspect

import numexpr
#
Expand All @@ -34,7 +35,8 @@ def __init__(self,
neurons_dir=None,
config_file=None,
random_seed=None,
connection_override_file=None):
connection_override_file=None,
honor_stay_inside=False):

"""Constructor
Expand Down Expand Up @@ -99,8 +101,12 @@ def __init__(self,

if struct_def:
for sn in struct_def:
print(f"Adding {sn} with {struct_def[sn]} neurons")
struct_func[sn](num_neurons=struct_def[sn], neurons_dir=neurons_dir)
if "stay_inside" in inspect.getargspec(struct_func[sn]).args:
print(f"Adding {sn} with {struct_def[sn]} neurons (stay_inside={honor_stay_inside})")
struct_func[sn](num_neurons=struct_def[sn], neurons_dir=neurons_dir, stay_inside=honor_stay_inside)
else:
print(f"Adding {sn} with {struct_def[sn]} neurons")
struct_func[sn](num_neurons=struct_def[sn], neurons_dir=neurons_dir)

if connection_override_file:
self.replace_connectivity(connection_file=connection_override_file)
Expand Down
15 changes: 1 addition & 14 deletions snudda/place/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ def __init__(self,
rc=None,
d_view=None,
h5libver=None,
raytrace_borders=False,
random_seed=None,
griddata_interpolation=False,
morphologies_stay_inside=True): # Setting this to true is 5x slower -- obsolete?
morphologies_stay_inside=True):

"""
Constructor.
Expand All @@ -67,7 +66,6 @@ def __init__(self,
rc : ipyparallel remote client
d_view : ipyparallel direct view object
h5libver : Version of h5py library
raytrace_borders (bool) : Should positions in border voxels be raytraces, slower but more accurate
random_seed (int) : Numpy random seed
griddata_interpolation (bool) : Should we interpolate density data (5x slower)
Expand Down Expand Up @@ -126,8 +124,6 @@ def __init__(self,
self.random_generator = None
self.rotate_helper = None

self.raytrace_borders = raytrace_borders

# This defines the neuron units/channels. The dictionary lists all the
# members of each unit, the neuronChannel gives the individual neurons
# channel membership
Expand Down Expand Up @@ -404,15 +400,6 @@ def parse_config(self, config_file=None, resort_neurons=True):
self.write_log(f"Unable to find mesh file {vol_def['meshFile']}")
sys.exit(-1)

# self.volume[volume_id]["mesh"] \
# = RegionMesh(mesh_file,
# d_view=d_view,
# raytrace_borders=self.raytrace_borders,
# d_min=vol_def["dMin"],
# bin_width=mesh_bin_width,
# log_file=mesh_logfile,
# random_seed=vol_seed[volume_id])

if "n_putative_points" in self.volume[volume_id]:
n_putative_points = int(self.volume[volume_id]["n_putative_points"])
else:
Expand Down

0 comments on commit 6512ef2

Please sign in to comment.