Exemplo n.º 1
0
def main():
    if len(sys.argv) > 1:
        nidm_original_version = sys.argv[1]
        nidm_version = nidm_original_version.replace(".", "")
    else:
        nidm_original_version = "dev"
        nidm_version = 'dev'

    # Retreive owl file for NIDM-Results
    if nidm_version == "dev":
        owl_file = os.path.join(TERMS_FOLDER, 'nidm-experiment.owl')
        import_files = glob.glob(os.path.join(NIDMPATH, "imports", '*.ttl'))
    else:
        owl_file = os.path.join(RELEASED_TERMS_FOLDER, \
            'nidm-experiment_'+nidm_version+'.owl')
        # For released version of the ontology imports are embedded
        import_files = None

    # check the file exists
    assert os.path.exists(owl_file)

    subcomponents =  collections.OrderedDict()

    subcomponents["Investigation"] = [NIDM['InvestigationCollection'],
        NIDM['InvestigationProcess'],NIDM['Model'],
        NIDM['ModelSpecification'],NIDM['Group'],
        NIDM['Contrast'], NIDM['Task'],NIDM['Condition']]
    subcomponents["Session"] = [NIDM['DataCollection'],NIDM['SessionAcquisition']]
    subcomponents["Serie"] = [NIDM['AnatomyImagingAcquisition'],
        NIDM['TaskBasedImagingAcquisition'], NIDM['AnatomicalScan'],
        NIDM['FunctionalScan'], NIDM['BehaviorAndConsitionOnsets'],
        NIDM['MRScanner'], NIDM['PresentationSoftware']]

    subcomponents["Project"] = [NIDM['ProjectObject']]
    subcomponents["Study"] = [NIDM['StudyObject']]
    subcomponents["Acquisition"] = [NIDM['AcquisitionObject']]
    subcomponents["Other"] = []

    # Add manually used and wasDerivedFrom because these are not stored in the
    # owl file (no relations yet!)
    used_by = {
    }
    generated_by = {
    }
    derived_from = {
    }

    owlspec = OwlSpecification(owl_file, import_files, "NIDM-Experiment",
        subcomponents, used_by, generated_by, derived_from,
        prefix=str(NIDM))

    if not nidm_version == "dev":
        owlspec.text = owlspec.text.replace("(under development)", nidm_original_version)
        owlspec.text = owlspec.text.replace("img/", "img/nidm-results_"+nidm_version+"/")

    component_name = "nidm-experiment"
    owlspec._header_footer(component=component_name, version=nidm_version)
    owlspec.write_specification(component=component_name, version=nidm_version)
Exemplo n.º 2
0
def main():
    if len(sys.argv) > 1:
        nidm_original_version = sys.argv[1]
        nidm_version = nidm_original_version.replace(".", "")
    else:
        nidm_original_version = "dev"
        nidm_version = 'dev'

    # Retreive owl file for NIDM-Results
    if nidm_version == "dev":
        owl_file = os.path.join(TERMS_FOLDER, 'nidm-experiment.owl')
        import_files = glob.glob(os.path.join(NIDMPATH, "imports", '*.ttl'))
    else:
        owl_file = os.path.join(RELEASED_TERMS_FOLDER, \
            'nidm-experiment_'+nidm_version+'.owl')
        # For released version of the ontology imports are embedded
        import_files = None

    # check the file exists
    assert os.path.exists(owl_file)

    subcomponents =  collections.OrderedDict()

    subcomponents["Investigation"] = [NIDM['InvestigationCollection'],
        NIDM['InvestigationProcess'],NIDM['Model'],
        NIDM['ModelSpecification'],NIDM['Group'],
        NIDM['Contrast'], NIDM['Task'],NIDM['Condition']]
    subcomponents["Session"] = [NIDM['DataCollection'],NIDM['SessionAcquisition']]
    subcomponents["Serie"] = [NIDM['AnatomyImagingAcquisition'],
        NIDM['TaskBasedImagingAcquisition'], NIDM['AnatomicalScan'],
        NIDM['FunctionalScan'], NIDM['BehaviorAndConditionOnsets'],
        NIDM['MRScanner'], NIDM['PresentationSoftware']]

    subcomponents["Project"] = [NIDM['ProjectObject']]
    subcomponents["Study"] = [NIDM['StudyObject']]
    subcomponents["Acquisition"] = [NIDM['AcquisitionObject']]
    subcomponents["Other"] = []

    # Add manually used and wasDerivedFrom because these are not stored in the
    # owl file (no relations yet!)
    used_by = {
    }
    generated_by = {
    }
    derived_from = {
    }

    owlspec = OwlSpecification(owl_file, import_files, "NIDM-Experiment",
        subcomponents, used_by, generated_by, derived_from,
        prefix=str(NIDM))

    if not nidm_version == "dev":
        owlspec.text = owlspec.text.replace("(under development)", nidm_original_version)
        owlspec.text = owlspec.text.replace("img/", "img/nidm-results_"+nidm_version+"/")

    component_name = "nidm-experiment"
    owlspec._header_footer(component=component_name, version=nidm_version)
    owlspec.write_specification(component=component_name, version=nidm_version)
Exemplo n.º 3
0
def main():
    if len(sys.argv) > 1:
        nidm_original_version = sys.argv[1]
        nidm_version = nidm_original_version.replace(".", "")
    else:
        nidm_original_version = "dev"
        nidm_version = 'dev'

    # Retreive owl file for NIDM-Results
    if nidm_version == "dev":
        owl_file = os.path.join(TERMS_FOLDER, 'nidm-experiment.owl')
        import_files = glob.glob(
            os.path.join(NIDM_EXPE_PATH, "imports", '*.ttl'))
    else:
        owl_file = os.path.join(RELEASED_TERMS_FOLDER, \
            'nidm-experiment_'+nidm_version+'.owl')
        # For released version of the ontology imports are embedded
        import_files = None

    # check the file exists
    assert os.path.exists(owl_file)

    subcomponents = collections.OrderedDict()

    subcomponents['Project'] = [
        NIDM['CoInvestigator'], NIDM['Gender'], NIDM['Group'],
        NIDM['ModelDesigner'], NIDM['ModelSpecification'],
        NIDM['PrincipalInvestigator'], NIDM['Project'], NIDM['Protocol'],
        NIDM['ResearchAssistant'], NIDM['SpecifiedPlan'], NIDM['Subject']
    ]
    subcomponents['Acquisition'] = [
        NIDM['Acquisition'], NIDM['AcquisitionDeviceOperator'],
        NIDM['AcquisitionMethod'], NIDM['AcquisitionModality'],
        NIDM['AcquisitionObject'], NIDM['AcquisitionObjectQuality'],
        NIDM['BehavioralInstrument'], NIDM['AuxiliaryFile'],
        NIDM['AuxiliaryFileCollection'], NIDM['DemographicsInstrument'],
        NIDM['ImageContrastType'], NIDM['ImageDataReconstruction'],
        NIDM['ImageUsageType'], NIDM['InformedConsentInstrument'],
        NIDM['InstrumentAdministrator'], NIDM['InstrumentUsageType'],
        NIDM['PerformedPlan'], NIDM['PresentationSoftware'],
        NIDM['ProcessedAcquisitionObject'], NIDM['RawAcquisitionObject'],
        NIDM['ReconstructedAcquisitionObject'], NIDM['Session'],
        NIDM['SessionObject'], NIDM['StimulusPresentationFile'],
        NIDM['StimulusResponseFile'], NIDM['Task']
    ]
    subcomponents['Magnetic Resonance Imaging'] = [
        NIDM['Anatomical'], NIDM['ArterialSpinLabeling'], NIDM['Cartesian'],
        NIDM['DICOMTagCollection'], NIDM['DiffusionTensor'],
        NIDM['DiffusionWeighted'], NIDM['DynamicContrastEnhanced'],
        NIDM['DynamicSusceptibilityContrast'], NIDM['EchoPlanar'],
        NIDM['FlowWeighted'], NIDM['Functional'], NIDM['ImageContrastType'],
        NIDM['ImageDataReconstruction'], NIDM['ImageUsageType'],
        NIDM['Inside-outSpiral'], NIDM['MagneticResonanceImaging'],
        NIDM['NuclearMagneticResonanceSpectroscopy'],
        NIDM['NuclearMagneticResonanceSpectroscopicImaging'],
        NIDM['Outside-inSpiral'], NIDM['ParallelImaging'],
        NIDM['ProtonDensityWeighted'], NIDM['PulseSequence'],
        NIDM['QuantitativeSusceptibilityMapping'], NIDM['Rectilinear'],
        NIDM['SimultaneousMultisliceMethod'], NIDM['Structural'],
        NIDM['SusceptibilityWeighted'], NIDM['SusceptibilityWeightedImaging'],
        NIDM['T1Weighted'], NIDM['T2StarWeighted'], NIDM['T2Weighted'],
        NIDM['b-ValueFile'], NIDM['b-VectorFile'],
        NIDM['k-spaceTraversalScheme'], NIDM['NIDM_0000152'],
        NIDM['NIDM_0000153'], NIDM['NIDM_0000154'], NIDM['NIDM_0000155']
    ]
    subcomponents['Electrophysiology'] = [
        NIDM['Amperometry'], NIDM['CurrentClamp'],
        NIDM['Electroencephalography'], NIDM['Electrocorticography'],
        NIDM['ElectrophysiologyRecording'],
        NIDM['ExtracellularElectrophysiologyRecording'],
        NIDM['FieldPotential'],
        NIDM['IntracellularElectrophysiologyRecording'],
        NIDM['Magnetoencephalography'], NIDM['MultiUnitReccording'],
        NIDM['SharpElectrode'], NIDM['SingleUnitReccording'],
        NIDM['PatchClamp'], NIDM['VoltageClamp']
    ]
    subcomponents['Devices'] = [
        NIDM['CurrentAmplifier'], NIDM['SignalGenerator'],
        NIDM['StimulusGenerator'], NIDM['StimulusIsolator'],
        NIDM['VoltageAmplifier'], NIDM['EyeTrackingDevice'],
        NIDM['HeartRateMonitor'], NIDM['Electrode'],
        NIDM['ElectroencephalographyAcquisitionDevice'],
        NIDM['MagneticResonanceImagingScanner'],
        NIDM['PositronEmissionTomographyScanner'],
        NIDM['SinglePhotonEmissionComputedTomographyScanner'],
        NIDM['MagnetoencephalographyAcquisitionDevice'],
        NIDM['MultielectrodeArray'], NIDM['Attenuator'],
        NIDM['RespirationRateMonitor'], NIDM['SignalFilter']
    ]
    subcomponents['Positron Emission Tomography'] = [
        NIDM['PositronEmissionTomography']
    ]
    subcomponents['X-ray Computed Tomography'] = [
        NIDM['X-rayComputedTomography']
    ]
    subcomponents["Other"] = []

    # Add manually used and wasDerivedFrom because these are not stored in the
    # owl file (no relations yet!)
    used_by = {}
    generated_by = {}
    derived_from = {}

    owlspec = OwlSpecification(owl_file,
                               import_files,
                               "NIDM-Experiment",
                               subcomponents,
                               used_by,
                               generated_by,
                               derived_from,
                               prefix=str(NIDM))

    if not nidm_version == "dev":
        owlspec.text = owlspec.text.replace("(under development)",
                                            nidm_original_version)
        owlspec.text = owlspec.text.replace(
            "img/", "img/nidm-results_" + nidm_version + "/")

    component_name = "nidm-experiment"
    owlspec._header_footer(component=component_name, version=nidm_version)
    owlspec.write_specification(component=component_name, version=nidm_version)
Exemplo n.º 4
0
def main(nidm_original_version):
    nidm_version = nidm_original_version.replace(".", "")

    # Retreive owl file for NIDM-Results
    if nidm_version == "dev":
        owl_file = os.path.join(TERMS_FOLDER, 'nidm-results.owl')
        import_files = glob.glob(os.path.join(NIDMPATH, "imports", '*.ttl'))

    else:
        owl_file = os.path.join(RELEASED_TERMS_FOLDER,
                                'nidm-results_' + nidm_version + '.owl')
        # For released version of the ontology imports are embedded
        import_files = None

    # check the file exists
    assert os.path.exists(owl_file)

    components = collections.OrderedDict()
    components["General"] = [NIDM_MAP]
    components["Parameters estimation"] = [
        NIDM_DATA, NIDM_ERROR_MODEL, NIDM_DESIGN_MATRIX,
        NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_PARAMETER_ESTIMATE_MAP,
        NIDM_GRAND_MEAN_MAP, NIDM_RESIDUAL_MEAN_SQUARES_MAP,
        NIDM_MASK_MAP, NIDM_RESELS_PER_VOXEL_MAP]
    components["Contrast estimation"] = [
        NIDM_CONTRAST_ESTIMATION,
        STATO_CONTRAST_WEIGHT_MATRIX, NIDM_CONTRAST_MAP, NIDM_STATISTIC_MAP,
        NIDM_CONTRAST_STANDARD_ERROR_MAP]
    components["Inference"] = [
        NIDM_INFERENCE, NIDM_HEIGHT_THRESHOLD, NIDM_EXTENT_THRESHOLD,
        NIDM_EXCURSION_SET_MAP, NIDM_CLUSTER_LABELS_MAP,
        NIDM_SEARCH_SPACE_MASK_MAP,
        NIDM_SIGNIFICANT_CLUSTER, NIDM_PEAK, NIDM_COORDINATE,
        NIDM_CONJUNCTION_INFERENCE, NIDM_CLUSTER_DEFINITION_CRITERIA,
        NIDM_DISPLAY_MASK_MAP, NIDM_PEAK_DEFINITION_CRITERIA]

    if nidm_version == 'dev':
        # For the developement version only list all terms that were not
        # referred to in other components
        components["Other"] = []

    # Add manually used and wasDerivedFrom because these are not stored in the
    # owl file
    used_by = {
        NIDM_DATA: [NIDM_MODEL_PARAMETERS_ESTIMATION],
        NIDM_ERROR_MODEL: [NIDM_MODEL_PARAMETERS_ESTIMATION],
        NIDM_DESIGN_MATRIX: [NIDM_MODEL_PARAMETERS_ESTIMATION,
                             NIDM_CONTRAST_ESTIMATION],
        NIDM_PARAMETER_ESTIMATE_MAP: [NIDM_CONTRAST_ESTIMATION],
        NIDM_RESIDUAL_MEAN_SQUARES_MAP: [NIDM_CONTRAST_ESTIMATION],
        NIDM_MASK_MAP: [NIDM_CONTRAST_ESTIMATION,
                        NIDM_MODEL_PARAMETERS_ESTIMATION],
        STATO_CONTRAST_WEIGHT_MATRIX: [NIDM_CONTRAST_ESTIMATION],
        NIDM_CONTRAST_MAP: [NIDM_INFERENCE],
        NIDM_STATISTIC_MAP: [NIDM_INFERENCE],
        NIDM_CLUSTER_DEFINITION_CRITERIA: [NIDM_INFERENCE],
        NIDM_DISPLAY_MASK_MAP: [NIDM_INFERENCE],
        NIDM_PEAK_DEFINITION_CRITERIA: [NIDM_INFERENCE],
        NIDM_RESELS_PER_VOXEL_MAP: [NIDM_INFERENCE]
    }
    generated_by = {
        NIDM_PARAMETER_ESTIMATE_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_RESIDUAL_MEAN_SQUARES_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_RESELS_PER_VOXEL_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_MASK_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_CONTRAST_MAP: NIDM_CONTRAST_ESTIMATION,
        NIDM_STATISTIC_MAP: NIDM_CONTRAST_ESTIMATION,
        NIDM_CONTRAST_STANDARD_ERROR_MAP: NIDM_CONTRAST_ESTIMATION,
    }

    derived_from = {
        NIDM_SIGNIFICANT_CLUSTER: NIDM_EXCURSION_SET_MAP,
        NIDM_PEAK: NIDM_SIGNIFICANT_CLUSTER,
        NIDM_CLUSTER_CENTER_OF_GRAVITY: NIDM_SIGNIFICANT_CLUSTER
    }

    if nidm_version == "020":
        # nidm namespaces were defined under incf.org (instead of purl)
        NIDM_INCF = Namespace('http://www.incf.org/ns/nidash/nidm#')
        SPM_INCF = Namespace('http://www.incf.org/ns/nidash/spm#')
        FSL_INCF = Namespace('http://www.incf.org/ns/nidash/fsl#')

        # The following classes were named differently in 0.2.0
        renaming = [(NIDM_EXCURSION_SET_MAP, NIDM_INCF['ExcursionSet']),
                    (NIDM_SEARCH_SPACE_MASK_MAP, NIDM_INCF['SearchSpaceMap']),
                    (NIDM_SIGNIFICANT_CLUSTER, NIDM_INCF['Cluster']),
                    (NIDM_ERROR_MODEL, NIDM_INCF['NoiseModel']),
                    (NIDM_CONTRAST_ESTIMATION,
                     NIDM_INCF['ContrastEstimation']),
                    (NIDM_CONTRAST_MAP, NIDM_INCF['ContrastMap']),
                    (NIDM_MAP, NIDM_INCF['Map']),
                    (NIDM_DATA, NIDM_INCF['Data']),
                    (NIDM_DESIGN_MATRIX, NIDM_INCF['DesignMatrix']),
                    (NIDM_MODEL_PARAMETERS_ESTIMATION,
                     NIDM_INCF['ModelParametersEstimation']),
                    (NIDM_GRAND_MEAN_MAP, NIDM_INCF['GrandMeanMap']),
                    (NIDM_RESIDUAL_MEAN_SQUARES_MAP,
                     NIDM_INCF['ResidualMeanSquaresMap']),
                    (NIDM_MASK_MAP, NIDM_INCF['MaskMap']),
                    (STATO_CONTRAST_WEIGHT_MATRIX,
                     NIDM_INCF['ContrastWeights']),
                    (NIDM_STATISTIC_MAP, NIDM_INCF['StatisticMap']),
                    (NIDM_CONTRAST_STANDARD_ERROR_MAP,
                     NIDM_INCF['ContrastStandardErrorMap']),
                    (NIDM_INFERENCE, NIDM_INCF['Inference']),
                    (NIDM_HEIGHT_THRESHOLD, NIDM_INCF['HeightThreshold']),
                    (NIDM_EXTENT_THRESHOLD, NIDM_INCF['ExtentThreshold']),
                    (NIDM_PEAK, NIDM_INCF['Peak']),
                    (NIDM_CLUSTER_LABELS_MAP, NIDM_INCF['ClusterLabelsMap']),
                    (NIDM_COORDINATE, NIDM_INCF['Coordinate']),
                    (NIDM_PARAMETER_ESTIMATE_MAP,
                     NIDM_INCF['ParameterEstimateMap']),
                    (NIDM_RESELS_PER_VOXEL_MAP,
                     SPM_INCF['ReselsPerVoxelMap']),
                    (NIDM_CLUSTER_CENTER_OF_GRAVITY,
                        FSL_INCF['CenterOfGravity'])]

        # MaskMap was sometimes called CustomMaskMap (when isUserDefined=true)
        components["Parameters estimation"].append(NIDM_INCF['CustomMaskMap'])

        # The following classes were not represented in 0.2.0
        components["Inference"].remove(NIDM_CLUSTER_DEFINITION_CRITERIA)
        components["Inference"].remove(NIDM_PEAK_DEFINITION_CRITERIA)
        components["Inference"].remove(NIDM_DISPLAY_MASK_MAP)
        components["Inference"].remove(NIDM_CONJUNCTION_INFERENCE)

        # The following classes were represented in another component in 0.2.0
        components["Parameters estimation"].remove(NIDM_RESELS_PER_VOXEL_MAP)

        del used_by[NIDM_CLUSTER_DEFINITION_CRITERIA]
        del used_by[NIDM_PEAK_DEFINITION_CRITERIA]
        del used_by[NIDM_DISPLAY_MASK_MAP]

        # SPM and FSL software were described using software-specific terms
        components["SPM-specific Concepts"] = [
            NIDM_INCF['SPM'], SPM_INCF['ReselsPerVoxelMap']]
        components["FSL-specific Concepts"] = [
            NIDM_INCF['FSL'], FSL_INCF['CenterOfGravity']]

        # Add manually used and wasDerivedFrom because these are not stored in
        # the owl file
        used_by[NIDM_INCF['CustomMaskMap']] = [
            NIDM_INCF['ModelParametersEstimation']]
        used_by[NIDM_MASK_MAP] = [NIDM_CONTRAST_ESTIMATION]

        # In version 0.2.0 "ErrorModel" was called "NoiseModel"
        components, used_by, generated_by, derived_from = _replace_term_by(
            renaming, components, used_by, generated_by, derived_from)

    owlspec = OwlSpecification(
        owl_file, import_files, "NIDM-Results",
        components, used_by, generated_by, derived_from, prefix=str(NIDM))

    owlspec._header_footer(component="nidm-results", version=nidm_version)

    if not nidm_version == "dev":
        if nidm_version == "110":
            # Previous version
            owlspec.text = owlspec.text.replace(
                "nidm-results_020.html", "nidm-results_100.html")
        elif nidm_version == "020":
            # Previous version
            owlspec.text = owlspec.text.replace(
                "nidm-results_020.html", "nidm-results_010.html")
        owlspec.text = dev_to_release(owlspec.text, nidm_original_version)

    owlspec.write_specification(component="nidm-results", version=nidm_version)
def main(nidm_original_version):
    nidm_version = nidm_original_version.replace(".", "")

    # Retreive owl file for NIDM-Results
    if nidm_version == "dev":
        owl_file = os.path.join(TERMS_FOLDER, 'nidm-results.owl')
        import_files = glob.glob(os.path.join(NIDMPATH, "imports", '*.ttl'))

    else:
        owl_file = os.path.join(RELEASED_TERMS_FOLDER,
                                'nidm-results_' + nidm_version + '.owl')
        # For released version of the ontology imports are embedded
        import_files = None

    # check the file exists
    assert os.path.exists(owl_file)

    components = collections.OrderedDict()
    components["General"] = [
        NIDM_RESULTS, NIDM_MAP, NIDM_COORDINATE_SPACE, SPM_SOFTWARE,
        FSL_SOFTWARE
    ]
    components["Parameters estimation"] = [
        NIDM_MODEL_PARAMETERS_ESTIMATION, NIDM_DATA, NIDM_DESIGN_MATRIX,
        NIDM_ERROR_MODEL, NIDM_GRAND_MEAN_MAP, NIDM_MASK_MAP,
        NIDM_PARAMETER_ESTIMATE_MAP, NIDM_RESELS_PER_VOXEL_MAP,
        NIDM_RESIDUAL_MEAN_SQUARES_MAP
    ]
    components["Contrast estimation"] = [
        NIDM_CONTRAST_ESTIMATION, STATO_CONTRAST_WEIGHT_MATRIX,
        NIDM_CONTRAST_MAP, NIDM_CONTRAST_STANDARD_ERROR_MAP,
        NIDM_CONTRAST_EXPLAINED_MEAN_SQUARE_MAP, NIDM_STATISTIC_MAP
    ]
    components["Inference"] = [
        NIDM_INFERENCE, NIDM_CLUSTER_DEFINITION_CRITERIA,
        NIDM_CLUSTER_LABELS_MAP, NIDM_COORDINATE, NIDM_DISPLAY_MASK_MAP,
        NIDM_EXCURSION_SET_MAP, NIDM_EXTENT_THRESHOLD, NIDM_HEIGHT_THRESHOLD,
        NIDM_PEAK, NIDM_PEAK_DEFINITION_CRITERIA, NIDM_SEARCH_SPACE_MASK_MAP,
        NIDM_SUPRA_THRESHOLD_CLUSTER
    ]

    if nidm_version == 'dev':
        # For the developement version only list all terms that were not
        # referred to in other components
        components["Other"] = []

    # Add manually used and wasDerivedFrom because these are not stored in the
    # owl file
    used_by = {
        NIDM_DATA: [NIDM_MODEL_PARAMETERS_ESTIMATION],
        NIDM_ERROR_MODEL: [NIDM_MODEL_PARAMETERS_ESTIMATION],
        NIDM_DESIGN_MATRIX:
        [NIDM_MODEL_PARAMETERS_ESTIMATION, NIDM_CONTRAST_ESTIMATION],
        NIDM_PARAMETER_ESTIMATE_MAP: [NIDM_CONTRAST_ESTIMATION],
        NIDM_RESIDUAL_MEAN_SQUARES_MAP: [NIDM_CONTRAST_ESTIMATION],
        NIDM_MASK_MAP:
        [NIDM_CONTRAST_ESTIMATION, NIDM_MODEL_PARAMETERS_ESTIMATION],
        STATO_CONTRAST_WEIGHT_MATRIX: [NIDM_CONTRAST_ESTIMATION],
        NIDM_CONTRAST_MAP: [NIDM_INFERENCE],
        NIDM_STATISTIC_MAP: [NIDM_INFERENCE],
        NIDM_CLUSTER_DEFINITION_CRITERIA: [NIDM_INFERENCE],
        NIDM_DISPLAY_MASK_MAP: [NIDM_INFERENCE],
        NIDM_PEAK_DEFINITION_CRITERIA: [NIDM_INFERENCE],
        NIDM_RESELS_PER_VOXEL_MAP: [NIDM_INFERENCE]
    }
    generated_by = {
        NIDM_PARAMETER_ESTIMATE_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_RESIDUAL_MEAN_SQUARES_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_RESELS_PER_VOXEL_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_MASK_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
        NIDM_CONTRAST_MAP: NIDM_CONTRAST_ESTIMATION,
        NIDM_STATISTIC_MAP: NIDM_CONTRAST_ESTIMATION,
        NIDM_CONTRAST_EXPLAINED_MEAN_SQUARE_MAP: NIDM_CONTRAST_ESTIMATION,
        NIDM_CONTRAST_STANDARD_ERROR_MAP: NIDM_CONTRAST_ESTIMATION,
        NIDM_GRAND_MEAN_MAP: NIDM_MODEL_PARAMETERS_ESTIMATION,
    }

    derived_from = {
        NIDM_SUPRA_THRESHOLD_CLUSTER: NIDM_EXCURSION_SET_MAP,
        NIDM_PEAK: NIDM_SUPRA_THRESHOLD_CLUSTER,
        NIDM_CLUSTER_CENTER_OF_GRAVITY: NIDM_SUPRA_THRESHOLD_CLUSTER
    }

    if nidm_version == "020":
        # nidm namespaces were defined under incf.org (instead of purl)
        NIDM_INCF = Namespace('http://www.incf.org/ns/nidash/nidm#')
        SPM_INCF = Namespace('http://www.incf.org/ns/nidash/spm#')
        FSL_INCF = Namespace('http://www.incf.org/ns/nidash/fsl#')

        # The following classes were named differently in 0.2.0
        renaming = [
            (NIDM_EXCURSION_SET_MAP, NIDM_INCF['ExcursionSet']),
            (NIDM_SEARCH_SPACE_MASK_MAP, NIDM_INCF['SearchSpaceMap']),
            (NIDM_SUPRA_THRESHOLD_CLUSTER, NIDM_INCF['Cluster']),
            (NIDM_ERROR_MODEL, NIDM_INCF['NoiseModel']),
            (NIDM_CONTRAST_ESTIMATION, NIDM_INCF['ContrastEstimation']),
            (NIDM_CONTRAST_MAP, NIDM_INCF['ContrastMap']),
            (NIDM_MAP, NIDM_INCF['Map']), (NIDM_DATA, NIDM_INCF['Data']),
            (NIDM_DESIGN_MATRIX, NIDM_INCF['DesignMatrix']),
            (NIDM_MODEL_PARAMETERS_ESTIMATION,
             NIDM_INCF['ModelParametersEstimation']),
            (NIDM_GRAND_MEAN_MAP, NIDM_INCF['GrandMeanMap']),
            (NIDM_RESIDUAL_MEAN_SQUARES_MAP,
             NIDM_INCF['ResidualMeanSquaresMap']),
            (NIDM_MASK_MAP, NIDM_INCF['MaskMap']),
            (STATO_CONTRAST_WEIGHT_MATRIX, NIDM_INCF['ContrastWeights']),
            (NIDM_STATISTIC_MAP, NIDM_INCF['StatisticMap']),
            (NIDM_CONTRAST_STANDARD_ERROR_MAP,
             NIDM_INCF['ContrastStandardErrorMap']),
            (NIDM_INFERENCE, NIDM_INCF['Inference']),
            (NIDM_HEIGHT_THRESHOLD, NIDM_INCF['HeightThreshold']),
            (NIDM_EXTENT_THRESHOLD, NIDM_INCF['ExtentThreshold']),
            (NIDM_PEAK, NIDM_INCF['Peak']),
            (NIDM_CLUSTER_LABELS_MAP, NIDM_INCF['ClusterLabelsMap']),
            (NIDM_COORDINATE, NIDM_INCF['Coordinate']),
            (NIDM_PARAMETER_ESTIMATE_MAP, NIDM_INCF['ParameterEstimateMap']),
            (NIDM_RESELS_PER_VOXEL_MAP, SPM_INCF['ReselsPerVoxelMap']),
            (NIDM_CLUSTER_CENTER_OF_GRAVITY, FSL_INCF['CenterOfGravity'])
        ]

        # MaskMap was sometimes called CustomMaskMap (when isUserDefined=true)
        components["Parameters estimation"].append(NIDM_INCF['CustomMaskMap'])

        # The following classes were not represented in 0.2.0
        components["Inference"].remove(NIDM_CLUSTER_DEFINITION_CRITERIA)
        components["Inference"].remove(NIDM_PEAK_DEFINITION_CRITERIA)
        components["Inference"].remove(NIDM_DISPLAY_MASK_MAP)
        components["Inference"].remove(NIDM_CONJUNCTION_INFERENCE)

        # The following classes were represented in another component in 0.2.0
        components["Parameters estimation"].remove(NIDM_RESELS_PER_VOXEL_MAP)

        del used_by[NIDM_CLUSTER_DEFINITION_CRITERIA]
        del used_by[NIDM_PEAK_DEFINITION_CRITERIA]
        del used_by[NIDM_DISPLAY_MASK_MAP]

        # SPM and FSL software were described using software-specific terms
        components["SPM-specific Concepts"] = [
            NIDM_INCF['SPM'], SPM_INCF['ReselsPerVoxelMap']
        ]
        components["FSL-specific Concepts"] = [
            NIDM_INCF['FSL'], FSL_INCF['CenterOfGravity']
        ]

        # Add manually used and wasDerivedFrom because these are not stored in
        # the owl file
        used_by[NIDM_INCF['CustomMaskMap']] = [
            NIDM_INCF['ModelParametersEstimation']
        ]
        used_by[NIDM_MASK_MAP] = [NIDM_CONTRAST_ESTIMATION]

        # In version 0.2.0 "ErrorModel" was called "NoiseModel"
        components, used_by, generated_by, derived_from = _replace_term_by(
            renaming, components, used_by, generated_by, derived_from)

    commentable = False
    if nidm_version == "dev":
        commentable = True

    intro = ""
    if nidm_version == "dev":
        intro = """
                <p>This section introduces neuroimaging results concepts with \
definitions and illustrative examples.</p>
            """

    owlspec = OwlSpecification(owl_file,
                               import_files,
                               "NIDM-Results",
                               components,
                               used_by,
                               generated_by,
                               derived_from,
                               prefix=str(NIDM),
                               commentable=commentable,
                               intro=intro)

    owlspec._header_footer(component="nidm-results", version=nidm_version)

    if not nidm_version == "dev":
        if nidm_version == "110":
            # Previous version
            owlspec.text = owlspec.text.replace("nidm-results_020.html",
                                                "nidm-results_100.html")
        elif nidm_version == "020":
            # Previous version
            owlspec.text = owlspec.text.replace("nidm-results_020.html",
                                                "nidm-results_010.html")
        owlspec.text = dev_to_release(owlspec.text, nidm_original_version)

    owlspec.write_specification(component="nidm-results", version=nidm_version)
Exemplo n.º 6
0
def main():
    if len(sys.argv) > 1:
        nidm_original_version = sys.argv[1]
        nidm_version = nidm_original_version.replace(".", "")
    else:
        nidm_original_version = "dev"
        nidm_version = 'dev'

    # Retreive owl file for NIDM-Results
    if nidm_version == "dev":
        owl_file = os.path.join(TERMS_FOLDER, 'nidm-experiment.owl')
        import_files = glob.glob(os.path.join(NIDM_EXPE_PATH, "imports", '*.ttl'))
    else:
        owl_file = os.path.join(RELEASED_TERMS_FOLDER, \
            'nidm-experiment_'+nidm_version+'.owl')
        # For released version of the ontology imports are embedded
        import_files = None

    # check the file exists
    assert os.path.exists(owl_file)

    subcomponents =  collections.OrderedDict()

    subcomponents['Project'] = [
        NIDM['CoInvestigator'], NIDM['Gender'],NIDM['Group'], NIDM['ModelDesigner'], NIDM['ModelSpecification'],
        NIDM['PrincipalInvestigator'], NIDM['Project'], NIDM['Protocol'], NIDM['ResearchAssistant'], 
        NIDM['SpecifiedPlan'], NIDM['Subject']
        ]
    subcomponents['Acquisition'] = [
        NIDM['Acquisition'],NIDM['AcquisitionDeviceOperator'],NIDM['AcquisitionMethod'],NIDM['AcquisitionModality'],
        NIDM['AcquisitionObject'], NIDM['AcquisitionObjectQuality'],NIDM['BehavioralInstrument'], 
        NIDM['AuxiliaryFile'], NIDM['AuxiliaryFileCollection'],  
        NIDM['ClinicalInstrument'], NIDM['DemographicsInstrument'],
        NIDM['ImageContrastType'], NIDM['ImageDataReconstruction'],
        NIDM['ImageUsageType'],NIDM['InformedConsentInstrument'],NIDM['InstrumentAdministrator'],
        NIDM['InstrumentUsageType'],
        NIDM['PerformedPlan'],NIDM['PresentationSoftware'],NIDM['ProcessedAcquisitionObject'],
        NIDM['RawAcquisitionObject'],NIDM['ReconstructedAcquisitionObject'], NIDM['Session'],
        NIDM['SessionObject'],NIDM['StimulusPresentationFile'], NIDM['StimulusResponseFile'],NIDM['Task']
        ]
    subcomponents['Magnetic Resonance Imaging'] = [
        NIDM['Anatomical'], NIDM['ArterialSpinLabeling'],NIDM['Cartesian'], 
        NIDM['DICOMTagCollection'], NIDM['DiffusionTensor'],NIDM['DiffusionWeighted'], 
        NIDM['DynamicContrastEnhanced'], NIDM['DynamicSusceptibilityContrast'],
        NIDM['EchoPlanar'], NIDM['FlowWeighted'],NIDM['Functional'],NIDM['ImageContrastType'],
        NIDM['ImageDataReconstruction'], NIDM['ImageUsageType'], NIDM['Inside-outSpiral'], 
        NIDM['MagneticResonanceImaging'],NIDM['NuclearMagneticResonanceSpectroscopy'],
        NIDM['NuclearMagneticResonanceSpectroscopicImaging'],NIDM['Outside-inSpiral'], NIDM['ParallelImaging'], 
        NIDM['ProtonDensityWeighted'],NIDM['PulseSequence'],NIDM['QuantitativeSusceptibilityMapping'],
        NIDM['Rectilinear'],NIDM['SimultaneousMultisliceMethod'], 
        NIDM['Structural'], 
        NIDM['SusceptibilityWeighted'],NIDM['SusceptibilityWeightedImaging'],
        NIDM['T1Weighted'], NIDM['T2StarWeighted'], NIDM['T2Weighted'],NIDM['b-ValueFile'],
        NIDM['b-VectorFile'], NIDM['k-spaceTraversalScheme'], NIDM['NIDM_0000152'], NIDM['NIDM_0000153'],
        NIDM['NIDM_0000154'], NIDM['NIDM_0000155']
        ]
    subcomponents['Electrophysiology'] = [
        NIDM['Amperometry'], NIDM['CurrentClamp'], 
        NIDM['Electroencephalography'], NIDM['Electrocorticography'],NIDM['ElectrophysiologyRecording'],
        NIDM['ExtracellularElectrophysiologyRecording'],NIDM['FieldPotential'],
        NIDM['IntracellularElectrophysiologyRecording'],NIDM['Magnetoencephalography'],
        NIDM['MultiUnitReccording'],  NIDM['SharpElectrode'], NIDM['SingleUnitReccording'], 
        NIDM['PatchClamp'], NIDM['VoltageClamp']
        ]
    subcomponents['Positron Emission Tomography'] = [NIDM['PositronEmissionTomography']]
    subcomponents['X-ray Computed Tomography'] = [NIDM['X-rayComputedTomography']]
    subcomponents["Other"] = []

    # Add manually used and wasDerivedFrom because these are not stored in the
    # owl file (no relations yet!)
    used_by = {
    }
    generated_by = {
    }
    derived_from = {
    }

    owlspec = OwlSpecification(owl_file, import_files, "NIDM-Experiment",
        subcomponents, used_by, generated_by, derived_from,
        prefix=str(NIDM))

    if not nidm_version == "dev":
        owlspec.text = owlspec.text.replace("(under development)", nidm_original_version)
        owlspec.text = owlspec.text.replace("img/", "img/nidm-results_"+nidm_version+"/")

    component_name = "nidm-experiment"
    owlspec._header_footer(component=component_name, version=nidm_version)
    owlspec.write_specification(component=component_name, version=nidm_version)