Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changes by Michael Stanway (April 2023) #51

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no BrazilData subdirectory in the archive I have received from @vmjanik. I will switch back to Test_Data next time we meet. Although this will not help with the other problem, this will demonstrate how to edit PRs.

% 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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the text in main is newer than suggested change - perhaps @michaelstanway used earlier version of the code, and in the meantime the comment was added? Of course, we have no way to figure out on which revision in the repository @michaelstanway's work was based, since Michael did not use version control. I am starting to suspect that this PR will be closed without merging, and we will have to manually recover ideas or go over text comments and pick up what is salvageable and helpful.

% 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
Loading