Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KomaMRIIO subpackage #231

Merged
merged 41 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3ca7139
Update phantom section with pelvis example in docs
beorostica Nov 22, 2023
1bd5ee7
Add simple contributing guidelines
beorostica Nov 22, 2023
f7d0fcc
Create simple KomaMRIIO subpackage
beorostica Nov 27, 2023
d69698e
Update ci.yml and minor dependency changes for KomaMRIIO
beorostica Nov 28, 2023
210c517
Remove MRI dependencies from KomaMRIIO
beorostica Nov 28, 2023
bb696e9
Update ci.yml to include codecov for KomaMRIIO
beorostica Nov 28, 2023
3eaace2
Merge branch 'master' into komaio
beorostica Nov 28, 2023
93dc116
Reexport ISMRMRDFile from KomaMRIIO
beorostica Nov 28, 2023
2150390
Use functions from KomaMRIIO and reduce number of dependencies
beorostica Nov 29, 2023
80ec68c
Use descriptive names for folders in KomaMRIIO
beorostica Nov 29, 2023
f65c8fc
Add KomaMRIIO version in UI
beorostica Nov 29, 2023
a4dbfdf
Update CONTRIBUTING.md
beorostica Nov 29, 2023
66e65f3
Merge branch 'master' into komaio
beorostica Nov 29, 2023
1e81082
Update ci.yml to consider develop environment of KomaMRIIO
beorostica Nov 29, 2023
5f8cb28
Consider KomaMRIIO in docs generation
beorostica Nov 29, 2023
072f361
Update contributing guidelines
beorostica Nov 29, 2023
721fef5
Include a Contributing section in README.md
beorostica Nov 29, 2023
094243f
Remove KomaMRIIO from KomaMRIPlots
beorostica Nov 29, 2023
9ca5957
Remove the unnecessary KomaMRIIO prefix from function calls
beorostica Nov 29, 2023
5ad188e
Update README.md with information about KomaMRIIO
beorostica Nov 29, 2023
36fd490
Update README.md
beorostica Nov 29, 2023
f425357
Update README.md
beorostica Nov 29, 2023
a7145d6
Use KomaMRIIO for testing KomaMRICore
beorostica Nov 30, 2023
f9e5e84
Utilize multiple-dispatching for simulation output
beorostica Nov 30, 2023
d9b7b2a
Change InteractiveUtils compat
beorostica Nov 30, 2023
1bef1df
Change name of simulation output structs
beorostica Nov 30, 2023
97640b1
Add consistent names for simulation output structs
beorostica Nov 30, 2023
8ff77bb
Move signal_to_raw_data() to KomaMRICore
beorostica Nov 30, 2023
dfda824
Remove simulation output functions
beorostica Nov 30, 2023
091441d
Remove InteractiveUtils package
beorostica Nov 30, 2023
2597f59
Remove show() tests
beorostica Nov 30, 2023
c85b5df
Simple tests for show() function
beorostica Nov 30, 2023
f42277c
Create a function to update encoding parameters for RawAcquisitionData
beorostica Dec 1, 2023
2115656
Fix XML saving
beorostica Dec 1, 2023
f624ab4
Rewrite insertNode function
beorostica Dec 1, 2023
2194121
Remove import for EncodingEncounters
beorostica Dec 1, 2023
7f48a03
Explicit types in ISMRMRD
cncastillo Dec 1, 2023
0a24ee5
Remove unnecessary KomaMRICore from test environment of KomaMRIIO
beorostica Dec 1, 2023
21e472e
Merge branch 'komaio' of github.com:cncastillo/KomaMRI.jl into komaio
beorostica Dec 1, 2023
7348532
Removes off-resonance from default UI phantom
cncastillo Dec 1, 2023
435f8f8
Merge branch 'master' into komaio
cncastillo Dec 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ jobs:
- uses: julia-actions/julia-runtest@v1
with:
project: KomaMRICore
- name: "KomaMRIIO dev setup"
shell: bash
run: |
julia --color=yes --project="KomaMRIIO" -e "using Pkg; Pkg.develop(PackageSpec(; path=\"./KomaMRICore\"));"
- uses: julia-actions/julia-buildpkg@v1
with:
project: KomaMRIIO
- uses: julia-actions/julia-runtest@v1
with:
project: KomaMRIIO
cncastillo marked this conversation as resolved.
Show resolved Hide resolved
- name: "KomaMRIPlots dev setup"
shell: bash
run: |
Expand Down
145 changes: 145 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<!-- omit in toc -->
# Contributing to KomaMRI

First off, thanks for taking the time to contribute! ❤️

All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉

> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
> - Star the project
> - Tweet about it
> - Refer this project in your project's readme
> - Mention the project at local meetups and tell your friends/colleagues

<!-- omit in toc -->
## Table of Contents

- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Your First Code Contribution](#your-first-code-contribution)
- [Improving The Documentation](#improving-the-documentation)
- [Styleguides](#styleguides)
- [Commit Messages](#commit-messages)
- [Join The Project Team](#join-the-project-team)



## I Have a Question

> If you want to ask a question, we assume that you have read the available [Documentation](https://cncastillo.github.io/KomaMRI.jl).

Before you ask a question, it is best to search for existing [Issues](https://github.com/cncastillo/KomaMRI.jl/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.

If you then still feel the need to ask a question and need clarification, we recommend the following:

- Open an [Issue](https://github.com/cncastillo/KomaMRI.jl/issues/new).
- Provide as much context as you can about what you're running into.
- Provide project and platform versions, depending on what seems relevant.

We will then take care of the issue as soon as possible.

<!--
You might want to create a separate issue tag for questions and include it in this description. People should then tag their issues accordingly.

Depending on how large the project is, you may want to outsource the questioning, e.g. to Stack Overflow or Gitter. You may add additional contact and information possibilities:
- IRC
- Slack
- Gitter
- Stack Overflow tag
- Blog
- FAQ
- Roadmap
- E-Mail List
- Forum
-->

## I Want To Contribute

> ### Legal Notice <!-- omit in toc -->
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.

### Reporting Bugs

<!-- omit in toc -->
#### Before Submitting a Bug Report

A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.

- Make sure that you are using the latest version.
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://cncastillo.github.io/KomaMRI.jl). If you are looking for support, you might want to check [this section](#i-have-a-question)).
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/cncastillo/KomaMRI.jl/issues?q=label%3Abug).
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
- Collect information about the bug:
- Stack trace (Traceback)
- OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
- Possibly your input and the output
- Can you reliably reproduce the issue? And can you also reproduce it with older versions?

<!-- omit in toc -->
#### How Do I Submit a Good Bug Report?

> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <[email protected]>.
<!-- You may add a PGP key to allow the messages to be sent encrypted as well. -->

We use GitHub issues to track bugs and errors. If you run into an issue with the project:

- Open an [Issue](https://github.com/cncastillo/KomaMRI.jl/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
- Explain the behavior you would expect and the actual behavior.
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
- Provide the information you collected in the previous section.

Once it's filed:

- The project team will label the issue accordingly.
- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).

<!-- You might want to create an issue template for bugs and errors that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->


### Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for KomaMRI, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.

<!-- omit in toc -->
#### Before Submitting an Enhancement

- Make sure that you are using the latest version.
- Read the [documentation](https://cncastillo.github.io/KomaMRI.jl) carefully and find out if the functionality is already covered, maybe by an individual configuration.
- Perform a [search](https://github.com/cncastillo/KomaMRI.jl/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.

<!-- omit in toc -->
#### How Do I Submit a Good Enhancement Suggestion?

Enhancement suggestions are tracked as [GitHub issues](https://github.com/cncastillo/KomaMRI.jl/issues).

- Use a **clear and descriptive title** for the issue to identify the suggestion.
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. <!-- this should only be included if the project has a GUI -->
- **Explain why this enhancement would be useful** to most KomaMRI users. You may also want to point out the other projects that solved it better and which could serve as inspiration.

<!-- You might want to create an issue template for enhancement suggestions that can be used as a guide and that defines the structure of the information to be included. If you do so, reference it here in the description. -->

<!-- TODO
### Your First Code Contribution

include Setup of env, IDE and typical getting started instructions?

### Improving The Documentation

Updating, improving and correcting the documentation

## Styleguides
### Commit Messages

## Join The Project Team
-->

<!-- omit in toc -->
## Attribution
This guide is based on the **contributing-gen**. [Make your own](https://github.com/bttger/contributing-gen)!
cncastillo marked this conversation as resolved.
Show resolved Hide resolved
76 changes: 76 additions & 0 deletions KomaMRICore/src/datatypes/Phantom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,79 @@ function brain_phantom3D(;ss=4,start_end=[160, 200])
)
return obj
end

"""
obj = pelvis_phantom2D(; ss=4)

Creates a two-dimensional pelvis Phantom struct.

# Keywords
- `ss`: (`::Integer`, `=4`) subsampling parameter

# Returns
- `obj`: (`::Phantom`) Phantom struct

# Examples
```julia-repl
julia> obj = pelvis_phantom2D(; ss=1)

julia> pelvis_phantom2D(obj, :ρ)
```
"""
function pelvis_phantom2D(; ss=4)

# Get data from .mat file
path = @__DIR__
data = MAT.matread(path*"/phantom/pelvis2D.mat")
class = data["pelvis3D_slice"][1:ss:end,1:ss:end]

# Define spin position vectors
Δx = .5e-3*ss
M, N = size(class)
FOVx = (M-1)*Δx # [m]
FOVy = (N-1)*Δx # [m]
x = -FOVx/2:Δx:FOVx/2 # spin coordinates
y = -FOVy/2:Δx:FOVy/2 # spin coordinates
x, y = x .+ y'*0, x*0 .+ y' # grid points

# Define spin property vectors
ρ = (class.==51)*.001 .+ # Air
(class.==102)*.86 .+ # Fat
(class.==153)*.9 .+ # SoftTissue
(class.==204)*.4 .+ # SpongyBone
(class.==255)*.2 # CorticalBone
T1 = (class.==51)*.001 .+ # Air
(class.==102)*366 .+ # Fat
(class.==153)*1200 .+ # SoftTissue
(class.==204)*381 .+ # SpongyBone
(class.==255)*100 # CorticalBone
T2 = (class.==51)*.001 .+ # Air
(class.==102)*70 .+ # Fat
(class.==153)*80 .+ # SoftTissue
(class.==204)*52 .+ # SpongyBone
(class.==255)*.3 # CorticalBone
T2s = (class.==51)*.001 .+ # Air
(class.==102)*70 .+ # Fat
(class.==153)*80 .+ # SoftTissue
(class.==204)*52 .+ # SpongyBone
(class.==255)*.3 # CorticalBone
Δw_fat = -220 * 2π
Δw = (class.==102) * Δw_fat # FAT1
T1 = T1*1e-3
T2 = T2*1e-3
T2s = T2s*1e-3

# Define and return the Phantom struct
obj = Phantom{Float64}(
name = "pelvis2D",
x = y[ρ.!=0],
y = x[ρ.!=0],
z = 0*x[ρ.!=0],
ρ = ρ[ρ.!=0],
T1 = T1[ρ.!=0],
T2 = T2[ρ.!=0],
T2s = T2s[ρ.!=0],
Δw = Δw[ρ.!=0],
)
return obj
end
Binary file added KomaMRICore/src/datatypes/phantom/pelvis2D.mat
Binary file not shown.
19 changes: 19 additions & 0 deletions KomaMRIIO/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 Carlos Castillo Passi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions KomaMRIIO/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name = "KomaMRIIO"
uuid = "fcf631a6-1c7e-4e88-9e64-b8888386d9dc"
authors = ["Carlos Castillo Passi <[email protected]>"]
version = "0.7.7"

[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
MAT = "23992714-dd62-5051-b70f-ba57cb901cac"
MRIBase = "f7771a9a-6e57-4e71-863b-6e4b6a2f17df"
MRIFiles = "5a6f062f-bf45-497d-b654-ad17aae2a530"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
KomaMRICore = "4baa4f4d-2ae9-40db-8331-a7d1080e3f4e"
Scanf = "6ef1bc8b-493b-44e1-8d40-549aa65c4b41"

[compat]
FileIO = "1"
HDF5 = "0.16, 0.17"
JLD2 = "0.4"
MAT = "0.10"
MRIBase = "0.3, 0.4"
MRIFiles = "0.1, 0.2"
Pkg = "1.4"
KomaMRICore = "0.7"
Scanf = "0.5"
julia = "1.6"
19 changes: 19 additions & 0 deletions KomaMRIIO/src/KomaMRIIO.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module KomaMRIIO

using KomaMRICore
using Scanf, FileIO, HDF5, MAT, JLD2 # IO related

include("io/Pulseq.jl")
include("io/JEMRIS.jl")
include("io/MRiLab.jl")
include("io/ISMRMRD.jl")

export read_seq # Pulseq
export signal_to_raw_data # ISMRMRD
export read_phantom_jemris, read_phantom_MRiLab # Phantom

# Package version: KomaMRIIO.__VERSION__
using Pkg
__VERSION__ = VersionNumber(Pkg.TOML.parsefile(joinpath(@__DIR__, "..", "Project.toml"))["version"])

end # module KomaMRIIO
Loading