Ejemplo n.º 1
0
    def generate_dax(self, daxfile):
        from Pegasus.DAX3 import ADAG, Job, File, Link

        # The DAX generator
        dax = ADAG("pipeline")

        # Some bits of metadata.  Shoulf put plenty more here.
        dax.metadata("owner", self.pipeline.owner)
        dax.metadata("basename", self.pipeline.basename)
        dax.metadata("version", self.pipeline.version)

        # string tag -> pegasus File object mapping of all the
        # inputs and outputs used by any pipeline stage.
        files = {}

        # First generate the overall inputs to the pipeline,
        # i.e. ones that are not generated by any other stage
        # but must be specified at the start
        for tag in self.pipeline.input_tags():
            path = self.info['inputs'].get(tag)
            files[tag] = File(path)

        # Now go through the pipeline in sequence.
        for stage_name, stage_class in self.pipeline.sequence():
            # The stage in the pipeline.  We describe the meaning of it
            # (which image it corresponds to)
            # in the transformation catalog generation
            job = Job(stage_name, id=stage_name)

            # Configuration files for this job.
            # These will not be built during the pipeline and must be
            # provided by the user
            for config_tag, config_filename in stage_class.config.items():
                filename = self.pipeline.cfg[stage_name]['config'][config_tag]
                config_path = os.path.join(self.config_dir(), filename)
                config = File(config_path)
                job.uses(config, link=Link.INPUT)

            # Input files for the job, either created by the user or by previous
            # stages.  In either case they should be in the "files" dictionary, because
            # precursor jobs will have been added before this one.
            for input_tag in stage_class.inputs.keys():
                job.uses(files[input_tag], link=Link.INPUT)

            # Output files from the job. These will be created by the job
            # and used by future jobs
            for output_tag, output_type in stage_class.outputs.items():
                output_filename = "{}.{}".format(output_tag, output_type)
                output = File(output_filename)
                job.uses(output,
                         link=Link.OUTPUT,
                         transfer=True,
                         register=True)
                files[output_tag] = output

            # Add this job to the pipeline
            dax.addJob(job)

            # Tell pegasus which jobs this one depends on.
            # The pipeline already knows this information.
            # The pipeline.sequence command runs through
            # the jobs in an order that guarantees that a job's predecessors are
            # always done before it is, so they will always exist in the dax by this point.
            for predecessor_name in self.pipeline.dependencies(stage_name):
                dax.depends(stage_name, predecessor_name)

        # Generate the final DAX XML file.
        dax.writeXML(open(daxfile, "w"))
Ejemplo n.º 2
0
from tvb.recon.dax.seeg_computation import SEEGComputation
from tvb.recon.dax.seeg_gain_computation import SeegGainComputation
from tvb.recon.dax.sensor_model import SensorModel
from tvb.recon.dax.source_model import SourceModel
from tvb.recon.dax.t1_processing import T1Processing
from tvb.recon.dax.tracts_generation import TractsGeneration

if __name__ == "__main__":
    if len(sys.argv) != 3:
        sys.stderr.write("Usage: %s DAXFILE\n" % (sys.argv[0]))
        sys.exit(1)
    daxfile = sys.argv[1]
    patient_file = sys.argv[2]

    dax = ADAG("TVB-PIPELINE")
    dax.metadata("created", time.ctime())

    config = Configuration(patient_file)

    subject = config.props[ConfigKey.SUBJECT]
    trg_subject = config.props[ConfigKey.TRGSUBJECT]

    atlas_suffix = AtlasSuffix.DEFAULT

    if config.props[ConfigKey.ATLAS] == Atlas.A2009S:
        atlas_suffix = AtlasSuffix.A2009S

    t1_processing = T1Processing(subject, config.props[ConfigKey.T1_FRMT], config.props[ConfigKey.T2_FLAG],
                                 config.props[ConfigKey.T2_FRMT], config.props[ConfigKey.FLAIR_FLAG],
                                 config.props[ConfigKey.FLAIR_FRMT], config.props[ConfigKey.OPENMP_THRDS],
                                 atlas_suffix)
Ejemplo n.º 3
0
from tvb.recon.dax.seeg_computation import SEEGComputation
from tvb.recon.dax.seeg_gain_computation import SeegGainComputation
from tvb.recon.dax.sensor_model import SensorModel
from tvb.recon.dax.source_model import SourceModel
from tvb.recon.dax.t1_processing import T1Processing
from tvb.recon.dax.tracts_generation import TractsGeneration

if __name__ == "__main__":
    if len(sys.argv) != 3:
        sys.stderr.write("Usage: %s DAXFILE\n" % (sys.argv[0]))
        sys.exit(1)
    daxfile = sys.argv[1]
    patient_file = sys.argv[2]

    dax = ADAG("TVB-PIPELINE")
    dax.metadata("created", time.ctime())

    config = Configuration(patient_file)

    subject = config.props[ConfigKey.SUBJECT]
    trg_subject = config.props[ConfigKey.TRGSUBJECT]

    atlas_suffix = AtlasSuffix.DEFAULT

    if config.props[ConfigKey.ATLAS] == Atlas.A2009S:
        atlas_suffix = AtlasSuffix.A2009S

    t1_processing = T1Processing(
        subject, config.props[ConfigKey.T1_FRMT],
        config.props[ConfigKey.T2_FLAG], config.props[ConfigKey.T2_FRMT],
        config.props[ConfigKey.FLAIR_FLAG], config.props[ConfigKey.FLAIR_FRMT],
Ejemplo n.º 4
0
#!/usr/bin/env python

import time
import argparse
from Pegasus.DAX3 import ADAG
from bnm.recon.pegasus.config import Configuration
from bnm.recon.pegasus.flirt import step_coregister_t1_dwi
from bnm.recon.pegasus.t1 import steps_recon_all
from bnm.recon.pegasus.diffusion import steps_dwi_preproc
from bnm.recon.pegasus.utils import write_dax

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Generate a BNM flow")
    parser.add_argument("patient_file")
    args = parser.parse_args()

    dax = ADAG("BNM")
    dax.metadata("name", "Brain Network Model Reconstruction WorkFlow")
    dax.metadata("created-at", time.ctime())
    dax.metadata("flow-configuration", args.patient_file)
    config = Configuration(args.patient_file)

    relevant_t1_job = steps_recon_all(dax, config)
    relevant_dwi_job = steps_dwi_preproc(dax, config.diffusion)
    step_coregister_t1_dwi(dax, config, relevant_t1_job, relevant_dwi_job)

    write_dax(dax, config.main_dax_path)
Ejemplo n.º 5
0
 def _init_job_graph(self) -> ADAG:
     ret = ADAG(self.name)
     ret.metadata("name", self.name)
     ret.metadata("createdby", self.created_by)
     return ret