anchor.diff: -﻿#r "System.Xml.Linq"
  -#r @"D:\Rajesh\Ephys\Data Analysis\FSharp\TitanSpikeSnippeter\SnippetMaster\bin\Release\SnippetMaster.exe"
  -#r @"D:\Rajesh\Ephys\Data Analysis\FSharp\FsPickler\bin\Release\FsPickler.dll"
  -#r @"D:\Rajesh\Ephys\Data Analysis\FSharp\TitanSpikeClusterer\TitanSpikeClusterer\bin\Release\TitanSpikeClusterer.exe"
  +#r "System.Xml.Linq"
  +#r @".\WorkerNodes\Clusterer\SnippetMaster.exe"
  +#r @".\WorkerNodes\Clusterer\FsPickler.dll"
  +#r @".\WorkerNodes\Clusterer\TitanSpikeClusterer.exe"
   
   open System.Xml.Linq
   open System.IO
  
positive.code:                 )
          )
  
  //For all channel groups
  //let fnums = 
  //  [|"635596782733480422"|]
  //  |> Array.map (fun fnum ->
  //    let esets = loadnTrodes (XElement.Load(sprintf @"%s\%s\%s\SnippeterSettings.xml" userpathlocal rat fnum).Element(xn "EIBElectrodePlacement"))
  //    fnum,(esets|>Array.map (fun (chgroup,xs) -> chgroup,Array.length xs))
  //  )
  
  ////For select channel groups
  let fnums = 
    [|"635596782733480422",[|"0"|]|]
    |> Array.map (fun (fnum,chgroups) ->
      let esets = loadnTrodes (XElement.Load(sprintf @"%s\%s\%s\SnippeterSettings.xml" userpathlocal rat fnum).Element(xn "EIBElectrodePlacement"))
      fnum,chgroups|>Array.map (fun chgroup -> 
          let _,xs = esets |> Array.find (fst>>(=)chgroup)
          chgroup,Array.length xs
      )
    )
  
  for (fnum,esets) in fnums do
      //dispttl ()    
      //createDirs ()
      for chgroup,nchans in esets do
          //savecluscmdazure fnum chgroup nchans 1
          //dispcluscmd fnum chgroup nchans 4
          //disptermcmd fnum 15 chgroup nchans 4
          //displevel2cmd fnum chgroup nchans
          //printfn "%A" (fnum,chgroup)
          //writeclus2indx fnum chgroup
          //saveclus2cmdazure fnum chgroup nchans
          //dispclus2cmd fnum chgroup nchans
          //computeoffslevel2 fnum chgroup
          dispautosortcmd fnum chgroup nchans
  
  saveautosortstimes fnums
  saveautosortmeta fnums
  allmergers 0.02 fnums //0.02 is the threshold for merging chains. Increase it to result in fewer mergers. Reasonable range is 0.0 - 0.1
  savel2stimes fnums
  savemergerdetails (fnums |> Array.map fst)
  
negative.code: 
  let cmdpath = @"& 'C:\Titanic\Clusterer"
  
  let intdatahostip = "140.247.178.16:5900" // IP address : port number of RESTful service on data-server. Could also be formatted as "localhost:5900"
  
  let extdatahostip = "140.247.178.16:5900" // IP address : port number of RESTful service on data-server
  
  let extdatahost = Remote extdatahostip
  
  let userpathlocal = @"\\140.247.178.65\Data" // local or network (samba) path to parent data directory on server
  
  let userpathremote = @"/root/Data" // path to parent data directory on server (used in queries to RESTful service)
  let rat = "Dataset_1" // folder in which datasets to be clustered is stored
  let minclussize = 15
  let numblocksperazuretask = 200
  let cmdfile = @"C:\cmds" // if clustering commands are to be saved to a text file (optional)
  if File.Exists(cmdfile) then File.Delete(cmdfile)
  
  let fnumsall () = 
  