Skip to content

Commit

Permalink
Removing 'scenario_id' attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
NewtonSander committed Jul 31, 2023
1 parent 008736f commit 0f80407
Show file tree
Hide file tree
Showing 26 changed files with 79 additions and 129 deletions.
5 changes: 0 additions & 5 deletions docs/api/make.md

This file was deleted.

10 changes: 0 additions & 10 deletions docs/api/scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,22 @@
::: neurotechdevkit.scenarios.Scenario0
options:
show_root_heading: true
members:
- scenario_id

::: neurotechdevkit.scenarios.Scenario1_2D
options:
show_root_heading: true
members:
- scenario_id

::: neurotechdevkit.scenarios.Scenario1_3D
options:
show_root_heading: true
members:
- scenario_id

::: neurotechdevkit.scenarios.Scenario2_2D
options:
show_root_heading: true
members:
- scenario_id

::: neurotechdevkit.scenarios.Scenario2_3D
options:
show_root_heading: true
members:
- scenario_id

::: neurotechdevkit.scenarios.Target
options:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/plot_adding_custom_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
num_points=1000,
)

scenario = ndk.make("scenario-0-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_0.value()
scenario.sources.clear()
scenario.add_source(source)
scenario.compile_problem(center_frequency=5e5)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/plot_customized_center_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

CENTER_FREQUENCY = 6e5

scenario = ndk.make("scenario-0-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_0.value()

# using default material layers
scenario.material_layers = ["water", "cortical_bone", "brain", "tumor"]
Expand Down
1 change: 0 additions & 1 deletion docs/examples/plot_full_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class FullScenario(Scenario2D):
https://asa.scitation.org/doi/pdf/10.1121/10.0013426
"""

scenario_id = "the_id_for_this_scenario"
"""
Target attributes:
target_id: the string id of the target.
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/plot_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# ## Rendering scenario
import neurotechdevkit as ndk

scenario = ndk.make("scenario-0-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_0.value()
scenario.compile_problem(center_frequency=5e5)
result = scenario.simulate_steady_state()
assert isinstance(result, ndk.results.SteadyStateResult2D)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/plot_multiple_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import neurotechdevkit as ndk

scenario = ndk.make("scenario-0-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_0.value()

s1 = ndk.sources.FocusedSource2D(
position=np.array([0.01, 0.0]),
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/plot_phased_array_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
num_points=1000,
)

scenario = ndk.make("scenario-1-2d-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_1_2D.value()
scenario.sources = [source]
scenario.compile_problem(center_frequency=5e5)
result = scenario.simulate_steady_state()
Expand All @@ -141,7 +141,7 @@
# delays are automatically computed when `focal_length` is defined. Let's explore how
# the API looks like:

scenario = ndk.make("scenario-1-2d-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_1_2D.value()

phased_array = ndk.sources.PhasedArraySource2D(
position=np.array([0.0, 0.0]),
Expand Down Expand Up @@ -175,7 +175,7 @@
# In the example below we apply monotonically increasing delays to mimic a
# counter-clockwise angle.

scenario = ndk.make("scenario-1-2d-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_1_2D.value()

phased_array = ndk.sources.PhasedArraySource2D(
position=np.array([0.0, 0.0]),
Expand Down Expand Up @@ -207,7 +207,7 @@
#
# The rest of the API is identical for both 2D and 3D scenarios.

scenario = ndk.make("scenario-1-3d-v0")
scenario_3d = ndk.BUILTIN_SCENARIOS.SCENARIO_1_3D.value()

phased_3d = ndk.sources.PhasedArraySource3D(
position=np.array([0.0, 0.0, 0.0]),
Expand All @@ -220,10 +220,10 @@
tilt_angle=30,
height=5.0e-3,
)
scenario.sources.clear()
scenario.add_source(phased_3d)
scenario.compile_problem(center_frequency=5e5)
results = scenario.simulate_steady_state()
scenario_3d.sources.clear()
scenario_3d.add_source(phased_3d)
scenario_3d.compile_problem(center_frequency=5e5)
results = scenario_3d.simulate_steady_state()
assert isinstance(results, ndk.results.SteadyStateResult3D)
results.render_steady_state_amplitudes()

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/plot_pulsed_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# %%
import neurotechdevkit as ndk

scenario = ndk.make("scenario-0-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_0.value()
scenario.compile_problem(center_frequency=5e5)
result = scenario.simulate_pulse()
assert isinstance(result, ndk.results.PulsedResult2D)
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/plot_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@

def plot_scenario(scenario_id):
print(f"Simulating scenario: {scenario_id}")
scenario = ndk.make(scenario_id)
scenario = ndk.BUILTIN_SCENARIOS[scenario_id].value()
scenario.compile_problem(center_frequency=5e5)
result = scenario.simulate_steady_state()
result.render_steady_state_amplitudes(show_material_outlines=False)


# %%
# Simulating scenario: scenario-0-v0
# Simulating scenario: scenario-0
# ===================================
plot_scenario("scenario-0-v0")
plot_scenario("scenario-0")

# %%
# Simulating scenario: scenario-1-2d-v0
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/plot_store_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
# Execute the following code in a computer with ndk installed
import neurotechdevkit as ndk

scenario = ndk.make("scenario-0-v0")
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_0.value()
scenario.compile_problem(center_frequency=5e5)
result = scenario.simulate_steady_state()
result.save_to_disk("scenario-0-v0-results.tar.gz")
result.save_to_disk("scenario-0-results.tar.gz")


# %%
Expand All @@ -27,7 +27,7 @@
# be loaded running the following code:
import neurotechdevkit as ndk # noqa: E402

result2 = ndk.load_result_from_disk("scenario-0-v0-results.tar.gz")
result2 = ndk.load_result_from_disk("scenario-0-results.tar.gz")
assert isinstance(result2, ndk.results.SteadyStateResult2D)
result2.render_steady_state_amplitudes(show_material_outlines=False)
# %%
9 changes: 3 additions & 6 deletions docs/examples/plot_time_reverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@
import neurotechdevkit as ndk

# Parameters
SCENARIO_NAME = "scenario-2-2d-v0"
CENTER_FREQUENCY = 5e5
NUM_ELEMENTS = 20
ELEMENT_WIDTH = 1.2e-3


# %%
# Helper function to make the scenario with a PhasedArraySource
def make_scenario(element_delays=None) -> ndk.scenarios.Scenario:
true_scenario = ndk.make(SCENARIO_NAME)
def make_scenario(element_delays=None):
true_scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_2_2D.value()

# define a phased-array source
default_source = true_scenario.sources[0]
Expand All @@ -58,7 +57,6 @@ def make_scenario(element_delays=None) -> ndk.scenarios.Scenario:
# %%
# ## Set up and visualize the forward scenario
true_scenario = make_scenario()
assert isinstance(true_scenario, ndk.scenarios.Scenario2D)
true_scenario.compile_problem(center_frequency=CENTER_FREQUENCY)
true_scenario.render_layout()

Expand All @@ -69,14 +67,13 @@ def make_scenario(element_delays=None) -> ndk.scenarios.Scenario:
# The point source is visualized as a gray dot.

# Reinitialize the scenario
reversed_scenario = ndk.make(SCENARIO_NAME)
reversed_scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_2_2D.value()
# and reverse the source
point_source = ndk.sources.PointSource2D(
position=true_scenario.target.center,
)
reversed_scenario.add_source(point_source)

assert isinstance(reversed_scenario, ndk.scenarios.Scenario2D)
reversed_scenario.compile_problem(center_frequency=CENTER_FREQUENCY)
reversed_scenario.render_layout()

Expand Down
26 changes: 14 additions & 12 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@ You can run `neurotechdevkit` inside a docker container with just a couple of st

1. Run the following command:

```
docker run -p 8888:8888 -it ghcr.io/agencyenterprise/neurotechdevkit:latest
```
```
docker run -p 8888:8888 -it ghcr.io/agencyenterprise/neurotechdevkit:latest
```

The command above will start a [Jupyter notebook](https://jupyterlab.readthedocs.io/en/stable/getting_started/overview.html) server with example notebooks you can use to explore `neurotechdevkit`. Use the printed URL to open it in your browser or connect to it using your IDE.
The command above will start a [Jupyter notebook](https://jupyterlab.readthedocs.io/en/stable/getting_started/overview.html) server with example notebooks you can use to explore `neurotechdevkit`. Use the printed URL to open it in your browser or connect to it using your IDE.

All changes you make to these files will be lost once you stop the docker container.
All changes you make to these files will be lost once you stop the docker container.

> **Note**:
>
> You can have persisting [Jupyter notebooks](https://jupyterlab.readthedocs.io/en/stable/getting_started/overview.html) by running
> ```
> docker run -p 8888:8888 -v $(pwd)/notebooks:/ndk/notebooks -it ghcr.io/agencyenterprise/neurotechdevkit:latest
> ```
> The command above will create a folder `notebooks` in your current directory where you can put your jupyter notebooks.
> You can have persisting [Jupyter notebooks](https://jupyterlab.readthedocs.io/en/stable/getting_started/overview.html) by running
>
> We recommend downloading the `.zip` file with example notebooks from this [link](https://agencyenterprise.github.io/neurotechdevkit/generated/gallery/gallery_jupyter.zip), and extracting it into your local `notebooks` folder so you can access them from the docker.
> ```
> docker run -p 8888:8888 -v $(pwd)/notebooks:/ndk/notebooks -it ghcr.io/agencyenterprise/neurotechdevkit:latest
> ```
>
> The command above will create a folder `notebooks` in your current directory where you can put your jupyter notebooks.
>
> We recommend downloading the `.zip` file with example notebooks from this [link](https://agencyenterprise.github.io/neurotechdevkit/generated/gallery/gallery_jupyter.zip), and extracting it into your local `notebooks` folder so you can access them from the docker.
### Local installation

Expand All @@ -49,7 +51,7 @@ To install and run **neurotechdevkit** locally check the [installation](https://
```python
import neurotechdevkit as ndk

scenario = ndk.make('scenario-0-v0')
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_0.value()
result = scenario.simulate_steady_state()
result.render_steady_state_amplitudes(show_material_outlines=False)
```
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/defining_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Users can specify the parameters and placement of sources, and add them to their
import neurotechdevkit as ndk
import numpy as np

scenario = ndk.make('scenario-2-2d-v0')
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_2_2D.value()

source = ndk.sources.FocusedSource2D(
position=np.array([0.19, 0.07]),
Expand Down Expand Up @@ -49,7 +49,7 @@ The 2D sources are for 2D scenarios and the 3D sources for 3D scenarios. The par
import neurotechdevkit as ndk
import numpy as np

scenario = ndk.make('scenario-2-2d-v0')
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_2_2D.value()

source_position = np.array([0.19, 0.07])
source = ndk.sources.PlanarSource2D(
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Now when running NDK simulations you should be able to see `platform=nvidiaX` in
```py
import neurotechdevkit as ndk

scenario = ndk.make('scenario-2-2d-v0')
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_2_2D.value()
result = scenario.simulate_steady_state()
result.render_steady_state_amplitudes()
```
Expand Down
12 changes: 6 additions & 6 deletions docs/usage/loading_scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ The following is all that's needed to load a pre-defined scenario:
```py
import neurotechdevkit as ndk

scenario = ndk.make('scenario-2-2d-v0')
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_2_2D.value()
```

The existing scenario ids are:

- `scenario-0-v0` (2D) - a simple quickstart toy scenario that enables users to dive in and experiment with their first simulation immediately.
- `scenario-1-3d-v0` (3D) - a scenario containing a flat 3-layer bone covered by skin, with water above the skin and brain below the bone. This is based on benchmark 4 of [Jean-Francois Aubry, et al.](https://doi.org/10.1121/10.0013426).
- `scenario-2-3d-v0` (3D) - a scenario containing a full skull and brain mesh immersed in water. This is based on benchmark 8 of [Jean-Francois Aubry, et al.](https://doi.org/10.1121/10.0013426).
- `scenario-1-2d-v0` (2D) - a 2D version of scenario 1.
- `scenario-2-2d-v0` (2D) - a 2D version of scenario 2.
- `scenario-0` (2D) - a simple quickstart toy scenario that enables users to dive in and experiment with their first simulation immediately.
- `scenario-1-3d` (3D) - a scenario containing a flat 3-layer bone covered by skin, with water above the skin and brain below the bone. This is based on benchmark 4 of [Jean-Francois Aubry, et al.](https://doi.org/10.1121/10.0013426).
- `scenario-2-3d` (3D) - a scenario containing a full skull and brain mesh immersed in water. This is based on benchmark 8 of [Jean-Francois Aubry, et al.](https://doi.org/10.1121/10.0013426).
- `scenario-1-2d` (2D) - a 2D version of scenario 1.
- `scenario-2-2d` (2D) - a 2D version of scenario 2.

All of these scenarios are immediately ready for visualization and simulation, with appropriate default parameters used where needed.

Expand Down
2 changes: 1 addition & 1 deletion docs/usage/running_simulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Running a simulation takes just a single function call.
```py
import neurotechdevkit as ndk

scenario = ndk.make('scenario-2-2d-v0')
scenario = ndk.BUILTIN_SCENARIOS.SCENARIO_2_2D.value()
result = scenario.simulate_steady_state()
result.render_steady_state_amplitudes()
```
Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ nav:
- Troubleshooting: usage/troubleshooting.md
- GPU support: usage/gpu.md
- API:
- Make: api/make.md
- Scenarios: api/scenarios.md
- Utils: api/utils.md
- Sources: api/sources.md
Expand Down
Loading

0 comments on commit 0f80407

Please sign in to comment.