This repository has been archived by the owner on May 18, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Rt/issue75 shim specs json #92
Draft
rtopfer
wants to merge
24
commits into
master
Choose a base branch
from
rt/issue75-ShimSpecs-json
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4409f83
add +img.read_nii.m from dev branch rt/+img
rtopfer fedca0d
Merge branch 'master' into rt/issue75-ShimSpecs-json
rtopfer a78565d
REF,DOC: Replace getnactivechannels() method with nChannels dependent…
rtopfer 386664f
BUG: Replace calls to ShimUse.customdisplay (deprecated) with fprintf
rtopfer 0089d5c
BUG: correct variable name
rtopfer fce7622
REF: Enable ShimSpecs object as optional input to ShimOpt() constructor
rtopfer 04b75c3
NEW: +b0shim/+coils/+greg package, containing specs.json (converted f…
rtopfer b00fd74
NEW: package +valid for generic validation functions; add mustBeA.m—c…
rtopfer b88c7cf
NEW: b0shim.Specs class to create ShimSpecs object from json file (pa…
rtopfer 2dbcb66
NEW: draft save_json() method in b0shim.Specs
rtopfer 19f8527
DOC: b0shim.Specs reformat
rtopfer a6ad608
BUG: ShimUse.m : Replace curly brackets with parentheses
rtopfer 93298ab
Merge branch 'master' into rt/issue75-ShimSpecs-json
rtopfer dfda2d4
DEL: +img folder (renamed on master to +imutils)
rtopfer 89d7ebf
REF: Minor changes to Shim -Com,-Specs and -Opt classes for _Greg/_re…
rtopfer ce9a8b4
NEW: +parts classes to form Shim Specs config: Channel.m and Port.m
rtopfer 091800e
REF: b0shim.Specs properties now include +parts.Channel, .Port
rtopfer 02c45e2
DOC,NEW: +b0shim.parts (class docs) and Contents.m (package doc)
rtopfer f60aa6f
NEW: read_/write_json standalone functions added to ./misc
rtopfer dc54fb5
DOC: +b0shim/+parts/ Channel.m and Port.m
rtopfer 9404bbe
REF, DOC: +b0shim.Specs simplify (move json I/O to standalone functio…
rtopfer 0209c5e
REF: Rename Specs --> Config (the class bears little semblance to the…
rtopfer 28c75ab
BUG: Add Parity property to b0shim.parts.Port
rtopfer c8224e2
NEW,DOCS: add example configuration scripts and documentation
rtopfer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"Adc": { | ||
"mVPerAdcCount": 2 | ||
}, | ||
"Id": { | ||
"systemName": "Greg", | ||
"channelNames": [ | ||
"Ch1", | ||
"Ch2", | ||
"Ch3", | ||
"Ch4", | ||
"Ch5", | ||
"Ch6", | ||
"Ch7", | ||
"Ch8" | ||
], | ||
"channelUnits": [ | ||
"[A]", | ||
"[A]", | ||
"[A]", | ||
"[A]", | ||
"[A]", | ||
"[A]", | ||
"[A]", | ||
"[A]" | ||
] | ||
}, | ||
"Amp": { | ||
"maxCurrentPerChannel": [ | ||
2.5, | ||
2.5, | ||
2.5, | ||
2.5, | ||
2.5, | ||
2.5, | ||
2.5, | ||
2.5 | ||
], | ||
"maxCurrentPerBank": 20, | ||
"nChannels": 8, | ||
"nActiveChannels": 8, | ||
"maxVoltagePerChannel": 2500, | ||
"staticChannels": [ | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true | ||
], | ||
"dynamicChannels": [ | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true | ||
] | ||
}, | ||
"Com": { | ||
"baudRate": 115200, | ||
"readTimeout": 500, | ||
"dataBits": 8, | ||
"stopBits": 1, | ||
"flowControl": "NONE", | ||
"parity": "NONE", | ||
"byteOrder": "bigEndian", | ||
"txRxDelay": 0.005, | ||
"updatePeriod": 0.1 | ||
}, | ||
"Dac": { | ||
"resolution": 8, | ||
"maxCurrent": 5, | ||
"referenceVoltage": 1250, | ||
"maximum": 26214 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
function [img,info,json] = read_nii( niiFile ) | ||
%READ_NII Load NIfTI image and header; and, when present, the accompanying .json sidecar | ||
% | ||
% [img, info] = read_nii( niiFile ) | ||
% [img, info, json] = read_nii( niiFile ) | ||
% | ||
% The input `niiFile` is the path to the NIfTI image as a string scalar or | ||
% character vector. When called with 2 output arguments, the function is | ||
% equivalent short-hand for | ||
% | ||
% info = niftiinfo( niiFile ); img = niftiread( info ) | ||
% | ||
% When called with the 3rd output argument, the function checks the parent | ||
% folder of `niiFile` for an identically named file but with a .json file extension. | ||
% When such a file is present, the 3rd output is returned as a struct via | ||
% `json = jsondecode( fileread( jsonFile ) );` otherwise, `json = []`. | ||
arguments | ||
niiFile(1,:) string {mustBeStringScalarOrCharVector, mustBeFile} ; | ||
end | ||
|
||
info = niftiinfo( niiFile ); | ||
img = niftiread( info ); | ||
|
||
if nargout < 3 | ||
return; | ||
end | ||
|
||
[folder, name] = fileparts( niiFile ); | ||
jsonFile = fullfile( folder, name + ".json" ); | ||
|
||
if isfile( jsonFile ) | ||
json = jsondecode( fileread( jsonFile ) ); | ||
else | ||
json = []; | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,11 +24,16 @@ | |||||
Shim.Field = [] ; | ||||||
Shim.Model = [] ; | ||||||
Shim.Aux = [] ; | ||||||
Shim.System.Specs = ShimSpecs_Greg() ; | ||||||
Shim.System.currents = zeros( Shim.System.Specs.Amp.nActiveChannels, 1 ) ; | ||||||
|
||||||
[ Field, Params, Specs] = ShimOpt.parseinput( varargin ) ; | ||||||
|
||||||
if isempty(Specs) | ||||||
Shim.System.Specs = ShimSpecs_Greg() ; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't we agree to use camelCase for variables? so having something like this:
Suggested change
or maybe that would break the code somewhere else and we should do another specific PR for changing formatting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. baby steps! |
||||||
else | ||||||
Shim.System.Specs = Specs ; | ||||||
end | ||||||
|
||||||
[ Field, Params ] = ShimOpt.parseinput( varargin ) ; | ||||||
Shim.System.currents = zeros( Shim.System.Specs.Amp.nActiveChannels, 1 ) ; | ||||||
|
||||||
Params = ShimOpt_Greg.assigndefaultparameters( Params ) ; | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if it's of any help, but for the records here is how SPM deals with BIDS: https://en.wikibooks.org/wiki/SPM/BIDS