From 475ad5178761c502e9745f95c9c33359e9a003d7 Mon Sep 17 00:00:00 2001 From: Tobias Knopp Date: Fri, 27 Aug 2021 15:52:48 +0200 Subject: [PATCH] store paths in reco files in a relative manner + release --- Project.toml | 2 +- src/DatasetStore/Reconstruction.jl | 37 ++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 40941475..06f7c21d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MPIFiles" uuid = "371237a9-e6c1-5201-9adb-3d8cfa78fa9f" authors = ["Tobias Knopp "] -version = "0.11.12" +version = "0.11.13" [deps] AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9" diff --git a/src/DatasetStore/Reconstruction.jl b/src/DatasetStore/Reconstruction.jl index ddbb404b..2e81c4ad 100644 --- a/src/DatasetStore/Reconstruction.jl +++ b/src/DatasetStore/Reconstruction.jl @@ -20,15 +20,15 @@ end function extendPath(d::MDFDatasetStore, p::AbstractString) if isabspath(p) - return p + return normpath(p) else A = joinpath(d.path, p) if isfile(A) - return A + return normpath(A) end B = joinpath(d.path, "..", p) if isfile(B) - return B + return normpath(B) end D = splitpath(p) if length(D) > 1 @@ -37,7 +37,7 @@ function extendPath(d::MDFDatasetStore, p::AbstractString) @info d.path @info C if isfile(C) - return C + return normpath(C) end end error("extendPath could not generate valid path. Something is wrong with @@ -59,6 +59,33 @@ function normalizePathsRecoDict!(d::MDFDatasetStore, recoParams::Dict) end end +function splitOffStorePath(path, foldername) + s = splitpath(path) + i = findfirst(s .== foldername) + if i != nothing + return joinpath(s[i:end]...) + else + return path + end +end + +function makeRelativePathsRecoDict!(recoParams::Dict) + coll = Dict((:measPath => "measurements"), (:SFPath => "calibrations"), + (:emptyMeasPath => "measurements")) + + for (key,foldername) in coll + if haskey(recoParams, key) + if isa(recoParams[key], AbstractString) + recoParams[key] = splitOffStorePath(recoParams[key],foldername) + elseif isa(recoParams[key], AbstractVector) + for l=1:length(recoParams[key]) + recoParams[key][l] = splitOffStorePath(recoParams[key][l],foldername) + end + end + end + end +end + # This functions searches for recoparams and returns the corresponding recoNumber # 0 indicates that the set of parameters was not found function findReco(d::MDFDatasetStore, study::Study, exp::Experiment, recoParams::Dict) @@ -105,6 +132,8 @@ function addReco(d::MDFDatasetStore, study::Study, exp::Experiment, image) filepath = joinpath(outputpath, string(recoNum)) + image.recoParams = makeRelativePathsRecoDict!(image.recoParams) + saveRecoData(filepath*".mdf", image) #save(filepath*".jld","recoParams",recoParams) end