Skip to content

Validator

Connection

Bases: Base

A single connection between two cells.

Parameters:

Name Type Description Default
pre

The pre-synaptic cell

required
post

The post-synaptic cell

required
weight

The weight of the connection, which could be the number of synapses or a normalized value.

required
Source code in cect/validation/Validator.py
354
355
356
357
358
359
360
361
362
363
364
365
366
367
@modelspec.define
class Connection(Base):
    """
    A single connection between two cells.

    Args:
        pre: The pre-synaptic cell
        post: The post-synaptic cell
        weight: The weight of the connection, which could be the number of synapses or a normalized value.
    """

    pre: str = field(validator=instance_of(str))
    post: str = field(validator=instance_of(str))
    weight: float = field(validator=instance_of(float))

ConnectionList

Bases: Base

A model of a list of connections of a specific synapse type.

Parameters:

Name Type Description Default
synapse

The type of synapse

required
total_nonzero_conns

Total nonzero connections

required
total_weight

Total weight of connections (optional)

required
num_cells

Number of cells (optional)

required
view

An optional string specifying a ConnectomeView to use, e.g. Neurons, Pharynx, etc. Numbers of conns will be checked inside that view

required
comment

A comment about how the data was found, e.g. taken from a spreadsheet

required
connections

The list of connections of this type

required
Source code in cect/validation/Validator.py
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
@modelspec.define
class ConnectionList(Base):
    """
    A model of a list of connections of a specific synapse type.

    Args:
        synapse: The type of synapse
        total_nonzero_conns: Total nonzero connections
        total_weight: Total weight of connections (optional)
        num_cells: Number of cells (optional)
        view: An optional string specifying a ConnectomeView to use, e.g. Neurons, Pharynx, etc. Numbers of conns will be checked inside that view
        comment: A comment about how the data was found, e.g. taken from a spreadsheet
        connections: The list of connections of this type
    """

    synapse: str = field(validator=instance_of(str))
    total_nonzero_conns: int = field(validator=instance_of(int))
    total_weight: float = field(validator=instance_of(float))
    num_cells: int = field(validator=instance_of(int))
    view: str = field(validator=instance_of(str))
    comment: str = field(validator=instance_of(str))
    connections: List[Connection] = field(factory=list)

ReaderExpectedData

Bases: Base

A model of expected data for a specific reader.

Parameters:

Name Type Description Default
reader

The name of the reader

required
connection_lists

The list of connection lists for this reader

required
Source code in cect/validation/Validator.py
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
@modelspec.define
class ReaderExpectedData(Base):
    """
    A model of expected data for a specific reader.

    Args:
        reader: The name of the reader
        connection_lists: The list of connection lists for this reader
    """

    reader: str = field(validator=instance_of(str))
    connection_lists: List[ConnectionList] = field(factory=list)

    def get_connection_list_by_synapse(self, synapse_type):
        """
        Get the connection list for a specific synapse type.

        Args:
            synapse_type: The type of synapse to get the connection list for


        Returns:            The connection list for the specified synapse type, or None if not found.
        """
        for conn_list in self.connection_lists:
            if (
                isinstance(conn_list, dict)
                and "synapse" in conn_list
                and conn_list["synapse"] == synapse_type
            ):
                return conn_list
            if conn_list.synapse == synapse_type:
                return conn_list
        return None

get_connection_list_by_synapse(synapse_type)

Get the connection list for a specific synapse type.

Parameters:

Name Type Description Default
synapse_type

The type of synapse to get the connection list for

required

Returns: The connection list for the specified synapse type, or None if not found.

Source code in cect/validation/Validator.py
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
def get_connection_list_by_synapse(self, synapse_type):
    """
    Get the connection list for a specific synapse type.

    Args:
        synapse_type: The type of synapse to get the connection list for


    Returns:            The connection list for the specified synapse type, or None if not found.
    """
    for conn_list in self.connection_lists:
        if (
            isinstance(conn_list, dict)
            and "synapse" in conn_list
            and conn_list["synapse"] == synapse_type
        ):
            return conn_list
        if conn_list.synapse == synapse_type:
            return conn_list
    return None

generate_reader_exp_data_obj(reader_name, source_files, additional_comment='')

A function to generate a ReaderExpectedData object which will list expected data as visually extracted from a source file, e.g. an Excel spreadsheet.

Parameters:

Name Type Description Default
reader_name

The name of the reader

required
source_files

A dict of syn types vs paths to the source files

required

Returns:

Type Description

A ReaderExpectedData object with the expected data for the reader.

Source code in cect/validation/Validator.py
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
def generate_reader_exp_data_obj(reader_name, source_files, additional_comment=""):
    """
    A function to generate a ReaderExpectedData object which will list expected data as visually extracted from a source file, e.g. an Excel spreadsheet.

    Args:
        reader_name: The name of the reader
        source_files: A dict of syn types vs paths to the source files

    Returns:
        A ReaderExpectedData object with the expected data for the reader.
    """
    # This is a placeholder implementation. In a real implementation, you would read the source files and extract the expected data.
    expected_data = ReaderExpectedData(reader=reader_name)

    for syn_class, source_file in source_files.items():
        chem_conns = ConnectionList(
            synapse=syn_class,
            comment=f"Data visually read in from {source_file}. {additional_comment}",
            total_nonzero_conns=-1,
        )

    expected_data.connection_lists.append(chem_conns)

    return expected_data