From 73776d674d251c8d9ddeff49289a10a93885563f Mon Sep 17 00:00:00 2001 From: ReneSkukies Date: Mon, 7 Oct 2024 12:03:49 +0000 Subject: [PATCH] rename get_info to extract_subject_id --- src/load.jl | 26 +++++++++++++------------- test/runtests.jl | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/load.jl b/src/load.jl index 487df66..ae46368 100644 --- a/src/load.jl +++ b/src/load.jl @@ -1,8 +1,8 @@ """ bids_layout(bidsPath::AbstractString; derivatives::Bool=true, - specificFolder::Union{Nothing,AbstractString}=nothing, - excludeFolder::Union{Nothing,AbstractString}=nothing, + specific_folder::Union{Nothing,AbstractString}=nothing, + exclude_folder::Union{Nothing,AbstractString}=nothing, ses::Union{Nothing,AbstractString}=nothing, task::Union{Nothing,AbstractString}=nothing, run::Union{Nothing,AbstractString}=nothing) @@ -12,9 +12,9 @@ Main function to load paths of all subjects in one bids_root folder. Will return ## Keywords - `derivatives::Bool = true`\\ Look for data in the derivatives folder -- `specificFolder::Union{Nothing,AbstractString} = nothing`\\ +- `specific_folder::Union{Nothing,AbstractString} = nothing`\\ Specify a specific folder name in either derivatives or bids_root to look for data. -- `excludeFolder::Union{Nothing,AbstractString} = nothing`\\ +- `exclude_folder::Union{Nothing,AbstractString} = nothing`\\ Exclude a specific folder from data detection. - `ses:Union{Nothing,AbstractString} = nothing`\\ Which session to load; loads all if nothing @@ -25,8 +25,8 @@ Main function to load paths of all subjects in one bids_root folder. Will return """ function bids_layout(bidsPath::AbstractString; derivatives::Bool=true, - specificFolder::Union{Nothing,AbstractString}=nothing, - excludeFolder::Union{Nothing,AbstractString}=nothing, + specific_folder::Union{Nothing,AbstractString}=nothing, + exclude_folder::Union{Nothing,AbstractString}=nothing, ses::Union{Nothing,AbstractString}=nothing, task::Union{Nothing,AbstractString}=nothing, run::Union{Nothing,AbstractString}=nothing) @@ -56,13 +56,13 @@ function bids_layout(bidsPath::AbstractString; push!(exclude, "derivatives") end - if excludeFolder !== nothing - exclude = push!(exclude, excludeFolder) + if exclude_folder !== nothing + exclude = push!(exclude, exclude_folder) end # Choose a specific folder in either ./ or ./derivatives - if specificFolder !== nothing - bidsPath = joinpath(bidsPath, specificFolder) + if specific_folder !== nothing + bidsPath = joinpath(bidsPath, specific_folder) end @@ -78,7 +78,7 @@ function bids_layout(bidsPath::AbstractString; # Add additional information for path in all_paths - get_info!(files_df, path) + extract_subject_id!(files_df, path) end # Check for multiple session/tasks/runs @@ -95,11 +95,11 @@ function bids_layout(bidsPath::AbstractString; end """ - get_info!(files_df, file) + extract_subject_id!(files_df, file) Internal function to get subject information from dataframe. """ - function get_info!(files_df, file) + function extract_subject_id!(files_df, file) # Make regex for parts regex_sub = r"sub-(\d+)" diff --git a/test/runtests.jl b/test/runtests.jl index 1af7d94..cf19df0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,40 +5,40 @@ using Logging ### -@testset "UnfoldBIDS.get_info!" begin +@testset "UnfoldBIDS.extract_subject_id!" begin # Write your tests here. - # Tests for get_info + # Tests for extract_subject_id files_df = DataFrame(Sub=[], Ses=[], Task=[], Run=[], File=[]) # Test case 1: All fields present file1 = "sub-01_ses-02_task-rest_run-01_bold.vhdr" - files_df = UnfoldBIDS.get_info!(files_df, file1) + files_df = UnfoldBIDS.extract_subject_id!(files_df, file1) @test isequal(files_df[1, :], DataFrame(Sub = "01", Ses = "02", Task = "rest", Run = "01", File = file1)[1,:]) # Test case 2: Missing run file2 = "sub-03_ses-04_task-taskname_bold.vhdr" - files_df = UnfoldBIDS.get_info!(files_df, file2) + files_df = UnfoldBIDS.extract_subject_id!(files_df, file2) @test isequal(files_df[2, :], DataFrame(Sub = "03", Ses = "04", Task = "taskname", Run = missing, File = file2)[1,:]) # Test case 3: Missing session and run file3 = "sub-05_task-taskname_bold.vhdr" - files_df = UnfoldBIDS.get_info!(files_df, file3) + files_df = UnfoldBIDS.extract_subject_id!(files_df, file3) @test isequal(files_df[3, :], DataFrame(Sub = "05", Ses = missing, Task = "taskname", Run = missing, File = file3)[1,:]) # Test case 4: Missing task and run file4 = "sub-06_ses-07_bold.vhdr" - files_df = UnfoldBIDS.get_info!(files_df, file4) + files_df = UnfoldBIDS.extract_subject_id!(files_df, file4) @test isequal(files_df[4, :], DataFrame(Sub = "06", Ses = "07", Task = missing, Run = missing, File = file4)[1,:]) # Test case 5: Only subject file5 = "sub-08_bold.vhdr" - files_df = UnfoldBIDS.get_info!(files_df, file5) + files_df = UnfoldBIDS.extract_subject_id!(files_df, file5) @test isequal(files_df[5, :], DataFrame(Sub = "08", Ses = missing, Task = missing, Run = missing, File = file5)[1,:]) # Test case 6: No matching pattern file6 = "no_pattern_here.vhdr" - files_df = UnfoldBIDS.get_info!(files_df, file6) + files_df = UnfoldBIDS.extract_subject_id!(files_df, file6) @test isequal(files_df[6, :], DataFrame(Sub = missing, Ses = missing, Task = missing, Run = missing, File = file6)[1,:]) end