Skip to content
Open
2 changes: 1 addition & 1 deletion doc_template/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Two popular tools for managing Python environments are `anaconda <https://anacon

.. code-block:: bash

conda create -y --name environment-name python=3.6
conda create -y --name environment-name python=3.7
conda activate environment-name

and using venv:
Expand Down
8 changes: 4 additions & 4 deletions neuron_morphology/lims_apical_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def convert_coords_str(coords_str: str, resolution=None):


def get_data(query):
host = os.getenv("DBHOST")
dbname = os.getenv("DBNAME")
user = os.getenv("DBREADER")
password = os.getenv("DBPASSWORD")
host = os.getenv("LIMS_HOST")
dbname = os.getenv("LIMS_DBNAME")
user = os.getenv("LIMS_USER")
password = os.getenv("LIMS_PASSWORD")
conn_str = f'host={host} dbname={dbname} user={user} password={password}'

data = {}
Expand Down
56 changes: 29 additions & 27 deletions neuron_morphology/snap_polygons/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,29 @@ def run_snap_polygons(
"""Finds and returns close fit boundaries. May write diagnostic images as
a side effect.
"""

if len(layer_polygons)==0:
raise ValueError("No polygons provided.")
# setup input geometries
geometries = Geometries()
geometries.register_polygons(layer_polygons)

# setup cortex boundaries
hull = geometries.convex_hull()
pia = trim_to_close(hull, surface_distance_threshold, pia_surface["path"])
white_matter = trim_to_close(
hull, surface_distance_threshold, wm_surface["path"]
)

geometries.register_surface("pia", pia)
geometries.register_surface("wm", white_matter)

pia_wm_vertices = get_vertices_from_two_lines(
pia.coords[:], white_matter.coords[:]
)
bounds = shapely.geometry.polygon.Polygon(pia_wm_vertices)

if pia_surface is not None and wm_surface is not None:
hull = geometries.convex_hull()
pia = trim_to_close(hull, surface_distance_threshold, pia_surface["path"])
white_matter = trim_to_close(
hull, surface_distance_threshold, wm_surface["path"]
)
geometries.register_surface("pia", pia)
geometries.register_surface("wm", white_matter)
pia_wm_vertices = get_vertices_from_two_lines(
pia.coords[:], white_matter.coords[:]
)
# is this ever a good idea? seems like it may cut too much
bounds = shapely.geometry.polygon.Polygon(pia_wm_vertices)
else:
bounds = geometries.convex_hull()

multipolygon_resolver = partial(
select_largest_subpolygon,
error_threshold=multipolygon_error_threshold
Expand All @@ -69,8 +72,8 @@ def run_snap_polygons(
boundaries = find_vertical_surfaces(
result_geos.polygons,
layer_order,
pia=geometries.surfaces["pia"],
white_matter=geometries.surfaces["wm"]
pia=geometries.surfaces.get("pia"),
white_matter=geometries.surfaces.get("wm")
)
result_geos.register_surfaces(boundaries)

Expand All @@ -83,20 +86,19 @@ def run_snap_polygons(
return results


class Parser(ArgSchemaParser):
"""An ArgschemaParser that can pull data from LIMS
"""
default_sources = \
ArgSchemaParser.default_sources + (FromLimsSource,)
default_schema=InputParameters
default_output_schema=OutputParameters

def main():
"""CLI entrypoint for snapping polygons
"""

class Parser(ArgSchemaParser):
"""An ArgschemaParser that can pull data from LIMS
"""
default_configurable_sources = \
ArgSchemaParser.default_configurable_sources + [FromLimsSource]

parser = Parser(
schema_type=InputParameters,
output_schema_type=OutputParameters
)
parser = Parser()

args = cp.deepcopy(parser.args)
logging.getLogger().setLevel(args.pop("log_level"))
Expand Down
Loading