示例#1
0
def processLCC():
    global lccOutputFileName
    
    global inputRoi_raw
    global inputRoi_xml
    global inputFiber_dat
    
    global bigGraphOutputFileName
    
    lcc.process_single_brain(inputRoi_xml, inputRoi_raw, bigGraphOutputFileName, lccOutputFileName)
示例#2
0
def processData(fiber_fn,
                roi_xml_fn,
                roi_raw_fn,
                graphs,
                graphInvariants,
                graphsize,
                run=False):
    '''
  Run graph building and other related scripts
  @param fiber_fn: fiber tract file
  @param roi_xml_fn: region of interest xml file
  @param roi_raw_fn: region of interest raw file

  @param graphs: Dir where biggraphs & smallgraphs are saved
  @param graphInvariants:  Dir where graph invariants are saved
  @param graphsize: the size of the graph 'big' or 'small'
  @param run: Whether or not to run processor intensive jobs. Default is - false so nothing is actually run
  '''
    if (run):
        import mrcap.svd as svd
        import mrcap.lcc as lcc
        print "Imported svd and lcc modules..."

    baseName = getFiberID(fiber_fn)  #VERY TEMPORARY

    smGrfn = os.path.join(graphs, (baseName + 'smgr.mat'))
    bgGrfn = os.path.join(graphs, (baseName + 'bggr.mat'))

    if (run):
        if (graphsize == 'small'):
            ''' Run gengraph SMALL & save output '''
            print("Running Small gengraph....")
            gengraph.genGraph(fiber_fn,
                              smGrfn,
                              roi_xml_fn,
                              roi_raw_fn,
                              bigGraph=False)

        elif (graphsize == 'big'):
            ''' Run gengrah BIG & save output '''
            print("\nRunning Big gengraph....")
            gengraph.genGraph(fiber_fn,
                              bgGrfn,
                              roi_xml_fn,
                              roi_raw_fn,
                              bigGraph=True)
        else:
            print '[ERROR]: Graphsize Unkwown'  # should never happen
    ''' Run LCC '''
    lccfn = os.path.join(graphInvariants, "LCC", (baseName + 'concomp.npy'))

    if (run):
        '''Should be big but we'll do small for now'''
        if (graphsize == 'big'):
            print "Running biggraph Largest connected component..."
            lcc.process_single_brain(bgGrfn, lccfn)
        if (graphsize == 'small'):
            print "Running smallgraph Largest connected component..."
            lcc.process_single_brain(smGrfn, lccfn)
    ''' Run Embed - SVD '''
    SVDfn = os.path.join(graphInvariants, "SVD", (baseName + 'embed.npy'))

    print("Running SVD....")
    if (run):
        if (graphsize == 'big'):
            print "Running SVD on biggraph"
            svd.embed_graph(lccfn, bgGrfn, SVDfn)
        if (graphsize == 'small'):
            print "Running SVD on smallgraph"
            svd.embed_graph(lccfn, smGrfn, SVDfn)

    print "Completed generating - graph, lcc & svd"
    return [smGrfn, bgGrfn, lccfn, SVDfn]
示例#3
0
def processData(fiber_fn, roi_xml_fn, roi_raw_fn,graphs, graphInvariants, graphsize, run = False):
  '''
  Run graph building and other related scripts
  @param fiber_fn: fiber tract file
  @param roi_xml_fn: region of interest xml file
  @param roi_raw_fn: region of interest raw file

  @param graphs: Dir where biggraphs & smallgraphs are saved
  @param graphInvariants:  Dir where graph invariants are saved
  @param graphsize: the size of the graph 'big' or 'small'
  @param run: Whether or not to run processor intensive jobs. Default is - false so nothing is actually run
  '''
  if (run):
    import mrcap.svd as svd
    import mrcap.lcc as lcc
    print "Imported svd and lcc modules..."

  baseName = getFiberID(fiber_fn) #VERY TEMPORARY

  smGrfn = os.path.join(graphs, (baseName +'smgr.mat'))
  bgGrfn = os.path.join(graphs, (baseName +'bggr.mat'))

  if (run):
    if (graphsize == 'small'):
      ''' Run gengraph SMALL & save output '''
      print("Running Small gengraph....")
      gengraph.genGraph(fiber_fn, smGrfn, roi_xml_fn, roi_raw_fn, bigGraph=False)

    elif(graphsize == 'big'):
      ''' Run gengrah BIG & save output '''
      print("\nRunning Big gengraph....")
      gengraph.genGraph(fiber_fn, bgGrfn, roi_xml_fn, roi_raw_fn, bigGraph=True)
    else:
      print '[ERROR]: Graphsize Unkwown' # should never happen

  ''' Run LCC '''
  lccfn = os.path.join(graphInvariants,"LCC", (baseName + 'concomp.npy'))

  if (run):
    '''Should be big but we'll do small for now'''
    if (graphsize == 'big'):
      print "Running biggraph Largest connected component..."
      lcc.process_single_brain(bgGrfn, lccfn)
    if (graphsize == 'small'):
      print "Running smallgraph Largest connected component..."
      lcc.process_single_brain(smGrfn, lccfn)

  ''' Run Embed - SVD '''
  SVDfn = os.path.join(graphInvariants,"SVD" ,(baseName + 'embed.npy'))

  print("Running SVD....")
  if (run):
    if (graphsize == 'big'):
      print "Running SVD on biggraph"
      svd.embed_graph(lccfn, bgGrfn, SVDfn)
    if (graphsize == 'small'):
      print "Running SVD on smallgraph"
      svd.embed_graph(lccfn, smGrfn, SVDfn)

  print "Completed generating - graph, lcc & svd"
  return [ smGrfn, bgGrfn, lccfn, SVDfn ]