|
|
|
@ -56,6 +56,7 @@ Routine{
|
|
|
|
~kmeans = FluidKMeans(s,2,100);
|
|
|
|
~kmeans = FluidKMeans(s,2,100);
|
|
|
|
~windowDS = FluidDataSet(s,\windowDS);
|
|
|
|
~windowDS = FluidDataSet(s,\windowDS);
|
|
|
|
~windowLS = FluidLabelSet(s,\windowLS);
|
|
|
|
~windowLS = FluidLabelSet(s,\windowLS);
|
|
|
|
|
|
|
|
~slices.dump{|x|~sliceDict = x;};
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
(
|
|
|
|
@ -63,47 +64,45 @@ Routine{
|
|
|
|
~indices = [0];
|
|
|
|
~indices = [0];
|
|
|
|
~head = 0;
|
|
|
|
~head = 0;
|
|
|
|
|
|
|
|
|
|
|
|
~sliceDict = Dictionary.new(4);
|
|
|
|
~tempDict = ();
|
|
|
|
~tempDict = Dictionary.new(4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~slices.dump{|x|~sliceDict = x;};
|
|
|
|
|
|
|
|
s.sync;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ( {~head <= (~originalslicesarray.size - ~winSize)},
|
|
|
|
while ( {~head <= (~originalslicesarray.size - ~winSize)},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var step = ~winSize - 1;
|
|
|
|
var step = ~winSize - 1;
|
|
|
|
var nbass = [];
|
|
|
|
var nbass = [];
|
|
|
|
|
|
|
|
~assignments = [];
|
|
|
|
//run a process on ~winSize items from ~head (with an overlap of 1)
|
|
|
|
//run a process on ~winSize items from ~head (with an overlap of 1)
|
|
|
|
//copy the items to a subdataset
|
|
|
|
//copy the items to a subdataset
|
|
|
|
~winSize.do{|i|
|
|
|
|
~winSize.do{|i|
|
|
|
|
~tempDict.put((i.asString), ~sliceDict["data"][(i+~head).asString]);//here one could curate which stats to take
|
|
|
|
~tempDict.put((i.asString), ~sliceDict["data"][(i+~head).asString]);//here one could curate which stats to take
|
|
|
|
"whichslices:%\n".postf(i+~head);
|
|
|
|
"whichslices:%\n".postf(i+~head);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
~windowDS.load(Dictionary.newFrom([\cols, 133, \data, ~tempDict]));
|
|
|
|
~windowDS.load(Dictionary.newFrom([\cols, 133, \data, ~tempDict]), action: {
|
|
|
|
s.sync;
|
|
|
|
"% - loaded\n".postf(~head);
|
|
|
|
"% - loaded\n".postf(~head);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//kmeans 2 and retrieve ordered array of class assignations
|
|
|
|
//kmeans 2 and retrieve ordered array of class assignations
|
|
|
|
~kmeans.fitPredict(~windowDS, ~windowLS, {|x| nbass = x;});
|
|
|
|
~kmeans.fitPredict(~windowDS, ~windowLS, action: {|x|
|
|
|
|
s.sync;
|
|
|
|
nbass = x;
|
|
|
|
"% - fitted1: ".postf(~head); nbass.postln;
|
|
|
|
"% - fitted1: ".postf(~head); nbass.postln;
|
|
|
|
|
|
|
|
|
|
|
|
// if (nbass.includes(0.0), { Routine{~kmeans.fitPredict(~windowDS, ~windowLS, {|x| nbass = x; "% - fitted2: ".postf(~head); nbass.postln; s.sync;});}.play; });
|
|
|
|
// if (nbass.includes(0.0), { Routine{~kmeans.fitPredict(~windowDS, ~windowLS, {|x| nbass = x; "% - fitted2: ".postf(~head); nbass.postln; s.sync;});}.play; });
|
|
|
|
|
|
|
|
|
|
|
|
~windowLS.dump{|x|~assignments = x.at("data").asSortedArray.flop[1].flatten;};
|
|
|
|
~windowLS.dump{|x|
|
|
|
|
s.sync;
|
|
|
|
~assignments = x.at("data").asSortedArray.flop[1].flatten;
|
|
|
|
"% - assigned ".postf(~head);
|
|
|
|
"% - assigned ".postf(~head);
|
|
|
|
|
|
|
|
|
|
|
|
~assignments.postln;
|
|
|
|
~assignments.postln;
|
|
|
|
|
|
|
|
|
|
|
|
step.do{|i|
|
|
|
|
|
|
|
|
if (~assignments[i+1] != ~assignments[i], {~indices= ~indices ++ (~originalslicesarray[~head+i+1])});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
step.do{|i|
|
|
|
|
|
|
|
|
if (~assignments[i+1] != ~assignments[i], {~indices= ~indices ++ (~originalslicesarray[~head+i+1])});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
s.sync;
|
|
|
|
~head = ~head + step;
|
|
|
|
~head = ~head + step;
|
|
|
|
"-----------------".postln;
|
|
|
|
"-----------------".postln;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//leftovers
|
|
|
|
//leftovers
|
|
|
|
if ( (~originalslicesarray.size - ~head) > 1, {
|
|
|
|
if ( (~originalslicesarray.size - ~head) > 1, {
|
|
|
|
//run a process on (a.size - ~head) items from ~head
|
|
|
|
//run a process on (a.size - ~head) items from ~head
|
|
|
|
|