Skip to content

Add input_spec declarations to dmri processing nodes#2

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-7a4e9a6f-d719-4ccb-b49c-aadb7f42ff35
Draft

Add input_spec declarations to dmri processing nodes#2
Copilot wants to merge 3 commits intomainfrom
copilot/fix-7a4e9a6f-d719-4ccb-b49c-aadb7f42ff35

Conversation

Copy link
Contributor

Copilot AI commented Sep 11, 2025

This PR implements input_spec declarations for all applicable dmri processing nodes, following the pattern established in dp_node_segm_brats_prepare.m. The input_spec system allows nodes to formally declare their expected input fields, improving documentation, validation, and user experience.

Changes Made

Added input_spec.add() declarations to 34 out of 43 dmri files, covering all nodes that process data inputs. Each declaration specifies:

  • Field name (e.g., 'dmri_fn', 'mask_fn')
  • Data type ('file', 'path', 'string', 'struct')
  • Mandatory flag (1 for required, 0 for optional)
  • Test flag (1 to test existence, 0 to skip)
  • Human-readable description

Example Implementation

Following the established pattern:

function obj = dp_node_dmri_dti(filter_sigma)
    obj.input_test = {'dmri_fn'};
    obj.output_test = {'md_fn', 'fa_fn', 's0_fn', 'fa_col_fn'};
    
    obj.input_spec.add('dmri_fn', 'file', 1, 1, 'Diffusion MRI nifti file');
    obj.input_spec.add('xps_fn', 'file', 1, 1, 'Experimental parameter set file');
    obj.input_spec.add('mask_fn', 'file', 0, 1, 'Brain mask file (optional)');
    obj.input_spec.add('opt', 'struct', 0, 0, 'Options structure (optional)');
    
    if (nargin > 0)
        obj.filter_sigma = filter_sigma;
    end
end

Coverage

All input fields appearing in i2o(), execute(), and po2i() methods are now properly declared across:

  • Basic processing: denoising, DTI analysis, smoothing, subsampling
  • Advanced analysis: QTI, powder averaging, sequence normalization
  • Motion/distortion correction: motion correction, TOPUP workflows
  • Registration: FLIRT registration and application
  • XPS management: parameter set creation from various sources
  • Utility functions: merging, MD calculation

Files Not Modified

9 files were intentionally left unchanged:

  • Workflow nodes (dp_node_dmri_topup, dp_node_dmri_disco) inherit specs from child nodes
  • Abstract templates (dp_node_dmri_preprocess_*) have no direct data inputs
  • IO-only validators (dp_node_dmri_topup_io) perform validation without processing
  • Special cases (dp_node_dmri_xps_force) force predefined parameters

This implementation ensures all input fields are properly documented and can be validated, improving the robustness and usability of the dmri processing pipeline.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits September 11, 2025 11:02
Co-authored-by: markus-nilsson <17831339+markus-nilsson@users.noreply.github.com>
Co-authored-by: markus-nilsson <17831339+markus-nilsson@users.noreply.github.com>
Copilot AI changed the title [WIP] I recently implemented a way to specify expected inputs. See dp_node_segm_brats_prepare.m for an example. Inputs that should be declared are all input fields appearing in the i2o and execute methods. Please go trough all files in dmri and suggest an up... Add input_spec declarations to dmri processing nodes Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants