Difference between revisions of "Process using.m"

From Spinach Documentation Wiki
Jump to: navigation, search
(→‎Examples)
(Update function See also links and function index membership)
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
−
{{DISPLAYTITLE:process_using.m}}
+
{{DISPLAYTITLE:process_using.m}} __NOTOC__
 
Applies the specified trained neural network file to the supplied DEER trace.
 
Applies the specified trained neural network file to the supplied DEER trace.
  
Line 6: Line 6:
 
     answers=process_using(deer_traces,net_file_name)
 
     answers=process_using(deer_traces,net_file_name)
  
−
==Arguments==
+
==Parameters==
  
 
   deer_traces  -  DEER trace(s) as a column vector or a  
 
   deer_traces  -  DEER trace(s) as a column vector or a  
Line 13: Line 13:
 
                   of the neural network.
 
                   of the neural network.
 
   
 
   
−
   net_file_name - the name of the checkpoint file produ-
+
   net_file_name - the name of the file containing a neu-
−
                   ced by the train() function of Matlab
+
                   ral network object, including full
−
                  Neural Network Toolbox, including the
+
                   path and the .mat extension.
−
                   full path and the .mat extension.
 
  
 
==Outputs==
 
==Outputs==
Line 22: Line 21:
 
   answers      - neural network output(s) as a column  
 
   answers      - neural network output(s) as a column  
 
                   vector or a matrix with multiple col-
 
                   vector or a matrix with multiple col-
−
                   umns. The number of rows mathes the  
+
                   umns. The number of rows matches the  
 
                   output size of the neural network.
 
                   output size of the neural network.
  
Line 28: Line 27:
 
In the example below, a batch of 100 distribution and DEER trace pairs are generated and processed using the generic distance distribution extraction netset:
 
In the example below, a batch of 100 distribution and DEER trace pairs are generated and processed using the generic distance distribution extraction netset:
  
−
        % Load the parameters
+
      % Load default parameters
−
        run('net_set_any_peaks/netset_params.m');  
+
      parameters=library_dd;  
 
   
 
   
−
        % Specify number of traces to produce
+
      % Number of traces
−
        parameters.ntraces=100;
+
      parameters.ntraces=100;
−
 
 
−
        % Generate test batch
 
−
        [time_grid,dist_grid,dist_distr_lib,~,~,deer_trace_lib,~,~,parameters]=deer_lib_gen([],parameters);
 
 
   
 
   
−
        % Run the analysis on the example set
+
      % Time and distance point counts
−
        answers=process_using(deer_trace_lib,'net_set_any_peaks/1.mat');
+
      parameters.np_time=512;
 +
      parameters.np_dist=512;
 +
 +
      % PDS experiment type
 +
      parameters.expt='deer';
 +
 +
      % Generate a test library
 +
      library=deer_lib_gen([],parameters);
 +
 +
      % Run the analysis on the example set
 +
      answers=process_using(deer_trace_lib,'net_set_any_peaks/1.mat');
  
 
Neural network answers can be plotted against the known right answers:
 
Neural network answers can be plotted against the known right answers:
  
 
         % Plot an example
 
         % Plot an example
−
         example=randi(100); figure;  
+
         example=randi(100); figure(); subplot(1,2,1);  
−
        subplot(1,2,1); plot(time_grid,deer_trace_lib(:,example));  
+
        plot(library.time_grid,library.deer_noisy_lib(:,example));  
−
         title('Input DEER trace');
+
         kgrid; ktitle('Input DEER trace'); kxlabel('time, s');
−
        xlabel('time, $\mu$s','interpreter','LaTex');
+
         subplot(1,2,2); plot(library.dist_grid,[answers(:,example) ...
−
         subplot(1,2,2); plot(dist_grid,[answers(:,example) dist_distr_lib(:,example)]);  
+
                                                library.dist_distr_lib(:,example)]);  
−
         title('Output distribution');
+
         kgrid; ktitle('Output distribution'); kxlabel('distance, $\rm{\AA}$');
−
        xlabel('distance, $\rm{\AA}$','interpreter','LaTex');
+
         klegend('Network answer','True answer');
−
         legend('Network answer','True answer');
+
 
 +
The resulting figure is shown below.
 +
 
 +
[[File:process_using.png]]
  
 
==Notes==
 
==Notes==
−
*Input and intermediate layers must have the [[train_one_net.m#tansig_func|'tansig']] activation function.
+
A CUDA capable GPU is not required by this function, it is generally fast enough even on minimal hardware.
−
*The function supports [[train_one_net.m#logsig_func|'logsig']] or [[train_one_net.m#tansig_func|'tansig']] activation functions in the output layer, if a different function is detected then an error will be returned.
 
−
*The function assumes a simple feed-forward network topology.
 
−
*The number of points in the input signal must equal the input layer dimensions.
 
−
*The output signal length will be defined by the network output layer dimensions.
 
−
*Network layers are '''not''' required to be uniform.
 
  
 
==See also==
 
==See also==
−
[[deernet.m]], [[netset_curate.m]]
+
[[deer_lib_gen.m]], [[deernet.m]], [[dist_range.m]], [[elexsys2deernet.m]], [[train_one_net.m]], [[Neural network module]], [[Built-in_experiments]]
−
 
 
  
−
''Version 2.2, authors: [[Ilya Kuprov]], [[Steve Worswick]]''
+
''Version 2.8, authors: [[Ilya Kuprov]], [[Steve Worswick]], [[Jake Keeley]]''

Latest revision as of 18:40, 6 June 2026

Applies the specified trained neural network file to the supplied DEER trace.

Syntax

    answers=process_using(deer_traces,net_file_name)

Parameters

  deer_traces  -  DEER trace(s) as a column vector or a 
                  matrix with multiple columns. The num-
                  ber of rows must match the input size 
                  of the neural network.

  net_file_name - the name of the file containing a neu-
                  ral network object, including full
                  path and the .mat extension.

Outputs

  answers       - neural network output(s) as a column 
                  vector or a matrix with multiple col-
                  umns. The number of rows matches the 
                  output size of the neural network.

Examples

In the example below, a batch of 100 distribution and DEER trace pairs are generated and processed using the generic distance distribution extraction netset:

      % Load default parameters
      parameters=library_dd; 

      % Number of traces
      parameters.ntraces=100;

      % Time and distance point counts
      parameters.np_time=512;
      parameters.np_dist=512;

      % PDS experiment type
      parameters.expt='deer';

      % Generate a test library
      library=deer_lib_gen([],parameters);

      % Run the analysis on the example set
      answers=process_using(deer_trace_lib,'net_set_any_peaks/1.mat');

Neural network answers can be plotted against the known right answers:

       % Plot an example
       example=randi(100); figure(); subplot(1,2,1); 
       plot(library.time_grid,library.deer_noisy_lib(:,example)); 
       kgrid; ktitle('Input DEER trace'); kxlabel('time, s');
       subplot(1,2,2); plot(library.dist_grid,[answers(:,example) ...
                                               library.dist_distr_lib(:,example)]); 
       kgrid; ktitle('Output distribution'); kxlabel('distance, $\rm{\AA}$');
       klegend('Network answer','True answer');

The resulting figure is shown below.

Process using.png

Notes

A CUDA capable GPU is not required by this function, it is generally fast enough even on minimal hardware.

See also

deer_lib_gen.m, deernet.m, dist_range.m, elexsys2deernet.m, train_one_net.m, Neural network module, Built-in_experiments

Version 2.8, authors: Ilya Kuprov, Steve Worswick, Jake Keeley