Skip to content

Commit

Permalink
Add changes by Michael Stanway (April 2023)
Browse files Browse the repository at this point in the history
Attempt to do PR #50 properly.
  • Loading branch information
Olexandr Konovalov committed Apr 2, 2024
1 parent 7dabc9d commit b7c5dbe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
23 changes: 14 additions & 9 deletions Category.m
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
classdef Category
% Represents a category of tonal waveforms.
% Contains methods for adding contours and calculating
% how much a given contour matches others in this category.
% how much a given contour matches others in this category, as well
% as updating the category with a new contour or removing the contour
% from a category.

properties
reference % The average of all contours in the category;
% this is what prospective members are compared to
size % The number of contours in this category
average_cont % The average of all contours in the category;
% this is what new contours are compared to.
num_conts % The number of contours which have already been categorised into this category
end

methods
function cat = Category(size, reference)
% Construct a new category from the given array, which must
% contain at least one contour
cat.size = size;
cat.reference = reference;
function cat = category(average_cont, numConts)
% Construct a category object. If numConts drops to be below
% zero, the category will need to be deleted from the network
% since it no longer contains any contours
cat.numConts = numConts;
cat.average_cont = average_cont;
end

function val = compare(cat, contour)
val = 0;
% Compare a given contour object with the reference contour and
% return a percentage match value
% TODO

% Incorporate the code from ARTwarp_Calculate_Match
end

function cat = add(cat, contour)
Expand Down
5 changes: 0 additions & 5 deletions Contour.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
% This class represents an abstraction of a tonal waveform
% Using ContourFactory, a dataset can be read into ARTwarp and turned into
% these base units (individual contours), which are then used by the
% neural network.

classdef Contour
% Represents a single tonal waveform
% Holds the raw frequency values as well as extrapolated variables
Expand Down
11 changes: 6 additions & 5 deletions ContourFactory.m
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
% A factory to import contour objects from a directory containing a dataset
% Ideally, this file should be ignored and only the created Contour objects
% interacted with.
% Datasets can contain both CSV and CTR files
% A factory to construct an object containing all the contours from within
% the data directory (this directory may contain both ctr and csv files)

classdef ContourFactory
methods (Static)
function contours_shuffled = load_contours(varargin)
% Loads all of the contours from the directory and then
% shuffles them

if length(varargin) == 1
dir_path = varargin{1};
else
dir_path = cd + "/Test_Data"; % temporarily the subdirectory ./Test_Data
dir_path = cd + "/BrazilData"; % temporarily the subdirectory ./Test_Data
end
% path = uigetdir('Select the folder containing the contour files') % loads folder
contours = [ ContourFactory.getCSV(dir_path), ContourFactory.getCTR(dir_path) ];
Expand Down
8 changes: 6 additions & 2 deletions NetworkFactory.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classdef NetworkFactory
% A factory to initialise the network to be used within an ARTwarp run.
% Summary of this class goes here
% Detailed explanation goes here

methods (Static)
Expand All @@ -9,9 +9,13 @@
net = Network(weights);
end


function load_network
% Load a saved network
% TODO: no idea how we would store networks
% This will need to include:
% Weights of each category
% Number of whistles that were previously contained
% in a category
end

function net = run_categorisation(network, contours, parameters)
Expand Down
2 changes: 1 addition & 1 deletion tst/network_test.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
assert(isequal(network.categories(network.num_categories), cat), "Problem with adding category.");

% Further tests can be added after compare function in Category.m has been
% implemented
% implemented

0 comments on commit b7c5dbe

Please sign in to comment.