def createMorphoMlFile(fileName):
    '''
    Create MorphoMl for every cell from cells collection
    '''
    neuroMlwriter = NeuroMlWriter(fileName)
    for cell in neurons:
        neuroMlwriter.addCell(cell)
    neuroMlwriter.writeDocumentToFile()
def createMorphoMlFile(fileName):
    '''
    Create MorphoMl File with all cells from neurons
    '''
    neuroMlwriter = NeuroMlWriter(fileName)
    for cell in neurons:
        neuroMlwriter.addCell(cell)
    neuroMlwriter.writeDocumentToFile()
    print "%s neurons was successful imported"%len(neurons)
def createMorphoMlFile(fileName, cell):
    '''
    Convert to new neuroml structures and write
    '''

    if not muscle_dict.has_key(cell.name):
        neuroMlwriter = NeuroMlWriter(fileName, cell.name)
        neuroMlwriter.addCell(cell)
        neuroMlwriter.writeDocumentToFile()
        return

    #
    # Incomplete code to use the neuroml interface to write the file,
    # used for muscles, doesn't produce good enough result on neurons yet.
    #

    seg0 = cell.segments[0].position
    soma = Segment(proximal=cvt_pt(seg0.proximal_point),
                   distal=cvt_pt(seg0.distal_point))
    soma.name = 'Soma'
    soma.id = 0


    axon_segments = []
    for seg1 in cell.segments[1:]:

        parent = SegmentParent(segments=seg1.parent)
        if seg1.position.proximal_point is None:
            p = None
        else:
            p = cvt_pt(seg1.position.proximal_point)

        axon_segment = Segment(proximal = p,
                               distal = cvt_pt(seg1.position.distal_point),
                               parent = parent)
        axon_segment.id = seg1.id
        axon_segment.name = seg1.name
        axon_segments.append(axon_segment)

    morphology = Morphology()
    morphology.segments.append(soma)
    morphology.segments += axon_segments
    morphology.id = 'morphology_' + cell.name

    nml_cell = neuroml_Cell()
    nml_cell.id = cell.name
    nml_cell.morphology = morphology

    doc = NeuroMLDocument()
    doc.cells.append(nml_cell)
    #addCell(doc, cell)
    doc.id = "TestNeuroMLDocument"
    writers.NeuroMLWriter.write(doc, "Output/%s.nml" % fileName)
def createMorphoMlFile(fileName, cell):
    '''
    Convert to new neuroml structures and write
    '''

    if not muscle_dict.has_key(cell.name):
        neuroMlwriter = NeuroMlWriter(fileName, cell.name)
        neuroMlwriter.addCell(cell)
        neuroMlwriter.writeDocumentToFile()
        return

    #
    # Incomplete code to use the neuroml interface to write the file,
    # used for muscles, doesn't produce good enough result on neurons yet.
    #

    seg0 = cell.segments[0].position
    soma = Segment(proximal=cvt_pt(seg0.proximal_point),
                   distal=cvt_pt(seg0.distal_point))
    soma.name = 'Soma'
    soma.id = 0

    axon_segments = []
    for seg1 in cell.segments[1:]:

        parent = SegmentParent(segments=seg1.parent)
        if seg1.position.proximal_point is None:
            p = None
        else:
            p = cvt_pt(seg1.position.proximal_point)

        axon_segment = Segment(proximal=p,
                               distal=cvt_pt(seg1.position.distal_point),
                               parent=parent)
        axon_segment.id = seg1.id
        axon_segment.name = seg1.name
        axon_segments.append(axon_segment)

    morphology = Morphology()
    morphology.segments.append(soma)
    morphology.segments += axon_segments
    morphology.id = 'morphology_' + cell.name

    nml_cell = neuroml_Cell()
    nml_cell.id = cell.name
    nml_cell.morphology = morphology

    doc = NeuroMLDocument()
    doc.cells.append(nml_cell)
    #addCell(doc, cell)
    doc.id = "TestNeuroMLDocument"
    writers.NeuroMLWriter.write(doc, "Output/%s.nml" % fileName)