Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
navipy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olivier Bertrand
navipy
Commits
f781a3c6
Commit
f781a3c6
authored
6 years ago
by
Olivier Bertrand
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' of gitlab.ub.uni-bielefeld.de:olivier.bertrand/navipy into develop
parents
37802b5a
d7816f3a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tutorials/02-recording-animal-trajectory.ipynb
+33
-1
33 additions, 1 deletion
tutorials/02-recording-animal-trajectory.ipynb
tutorials/03-rendering-along-trajectory.ipynb
+1
-1
1 addition, 1 deletion
tutorials/03-rendering-along-trajectory.ipynb
with
34 additions
and
2 deletions
tutorials/02-recording-animal-trajectory.ipynb
+
33
−
1
View file @
f781a3c6
...
@@ -161,6 +161,38 @@
...
@@ -161,6 +161,38 @@
"mytraj.to_csv(csvtrajfile)\n",
"mytraj.to_csv(csvtrajfile)\n",
"mytraj.head()"
"mytraj.head()"
]
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### From csv to navipy\n",
"\n",
"Navipy can read csv files with 7 columns and a two line headers\n",
"\n",
"<table>\n",
"<tr>\n",
"<td>location</td>\n",
"<td>location</td>\n",
"<td>location</td>\n",
"<td>rzyx</td>\n",
"<td>rzyx</td>\n",
"<td>rzyx</td>\n",
"</tr>\n",
"<tr>\n",
"<td>x</td>\n",
"<td>y</td>\n",
"<td>z</td>\n",
"<td>alpha_0</td>\n",
"<td>alpha_1</td>\n",
"<td>alpha_2</td>\n",
"</tr>\n",
"</table>\n",
"\n",
"But you may have csv file with a different format.\n",
"\n",
"Here we are going to show, how to convert your csv file format to the one required by navipy"
]
}
}
],
],
"metadata": {
"metadata": {
...
@@ -179,7 +211,7 @@
...
@@ -179,7 +211,7 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.6.
5
"
"version": "3.6.
3
"
}
}
},
},
"nbformat": 4,
"nbformat": 4,
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Recording animal trajectory
# Recording animal trajectory
# Conversion to navipy trajectories
# Conversion to navipy trajectories
### From Matlab to navipy
### From Matlab to navipy
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
scipy.io
import
loadmat
from
scipy.io
import
loadmat
import
numpy
as
np
import
numpy
as
np
import
os
import
os
from
navipy.tools.trajectory
import
Trajectory
from
navipy.tools.trajectory
import
Trajectory
trajfile
=
'
../navipy/resources/sample_experiment/Lobecke_JEB_2018/Y101_OBFlight_0001.mat
'
trajfile
=
'
../navipy/resources/sample_experiment/Lobecke_JEB_2018/Y101_OBFlight_0001.mat
'
csvtrajfile
,
_
=
os
.
path
.
splitext
(
trajfile
)
csvtrajfile
,
_
=
os
.
path
.
splitext
(
trajfile
)
csvtrajfile
=
csvtrajfile
+
'
.csv
'
csvtrajfile
=
csvtrajfile
+
'
.csv
'
mymat
=
loadmat
(
trajfile
)
mymat
=
loadmat
(
trajfile
)
# matlab files are loaded in a dictionary
# matlab files are loaded in a dictionary
# we need to identify, under which key the trajectory has been saved
# we need to identify, under which key the trajectory has been saved
print
(
mymat
.
keys
())
print
(
mymat
.
keys
())
key
=
'
trajectory
'
key
=
'
trajectory
'
# Arrays are placed in a tupple. We need to access the level
# Arrays are placed in a tupple. We need to access the level
# of the array itself.
# of the array itself.
mymat
=
mymat
[
key
][
0
][
0
][
0
]
mymat
=
mymat
[
key
][
0
][
0
][
0
]
# The array should be a numpy array, and therefore as the .shape function
# The array should be a numpy array, and therefore as the .shape function
# to display the array size:
# to display the array size:
print
(
mymat
.
shape
)
print
(
mymat
.
shape
)
# In this example the array has 7661 rows and 4 columns
# In this example the array has 7661 rows and 4 columns
# the columns are: x,y,z, yaw. Therefore pitch and roll were assumed to be constant (here null)
# the columns are: x,y,z, yaw. Therefore pitch and roll were assumed to be constant (here null)
# We can therefore init a trajectory with the convention for rotation
# We can therefore init a trajectory with the convention for rotation
# often yaw-pitch-roll (i.e. 'rzyx') and with indeces the number of sampling points we have
# often yaw-pitch-roll (i.e. 'rzyx') and with indeces the number of sampling points we have
# in the trajectory
# in the trajectory
rotconvention
=
'
rzyx
'
rotconvention
=
'
rzyx
'
indeces
=
np
.
arange
(
0
,
mymat
.
shape
[
0
])
indeces
=
np
.
arange
(
0
,
mymat
.
shape
[
0
])
mytraj
=
Trajectory
(
rotconv
=
rotconvention
,
indeces
=
indeces
)
mytraj
=
Trajectory
(
rotconv
=
rotconvention
,
indeces
=
indeces
)
# We now can assign the values
# We now can assign the values
mytraj
.
x
=
mymat
[:,
0
]
mytraj
.
x
=
mymat
[:,
0
]
mytraj
.
y
=
mymat
[:,
1
]
mytraj
.
y
=
mymat
[:,
1
]
mytraj
.
z
=
mymat
[:,
2
]
mytraj
.
z
=
mymat
[:,
2
]
mytraj
.
alpha_0
=
mymat
[:,
3
]
mytraj
.
alpha_0
=
mymat
[:,
3
]
mytraj
.
alpha_1
=
0
mytraj
.
alpha_1
=
0
mytraj
.
alpha_2
=
0
mytraj
.
alpha_2
=
0
# We can then save mytraj as csv file for example
# We can then save mytraj as csv file for example
mytraj
.
to_csv
(
csvtrajfile
)
mytraj
.
to_csv
(
csvtrajfile
)
mytraj
.
head
()
mytraj
.
head
()
```
```
%% Output
%% Output
dict_keys(['__header__', '__version__', '__globals__', 'trajectory', 'nests', 'cylinders'])
dict_keys(['__header__', '__version__', '__globals__', 'trajectory', 'nests', 'cylinders'])
(7661, 4)
(7661, 4)
location rzyx
location rzyx
x y z alpha_0 alpha_1 alpha_2
x y z alpha_0 alpha_1 alpha_2
0 3.056519 -214.990482 9.330593 2.79751 0 0
0 3.056519 -214.990482 9.330593 2.79751 0 0
1 4.611665 -215.020314 8.424138 2.80863 0 0
1 4.611665 -215.020314 8.424138 2.80863 0 0
2 4.556650 -214.593236 9.185016 2.81407 0 0
2 4.556650 -214.593236 9.185016 2.81407 0 0
3 4.643091 -213.829769 10.542035 2.82704 0 0
3 4.643091 -213.829769 10.542035 2.82704 0 0
4 4.647302 -214.431592 7.461187 2.82896 0 0
4 4.647302 -214.431592 7.461187 2.82896 0 0
%% Cell type:markdown id: tags:
### From csv to navipy
Navipy can read csv files with 7 columns and a two line headers
<table>
<tr>
<td>
location
</td>
<td>
location
</td>
<td>
location
</td>
<td>
rzyx
</td>
<td>
rzyx
</td>
<td>
rzyx
</td>
</tr>
<tr>
<td>
x
</td>
<td>
y
</td>
<td>
z
</td>
<td>
alpha_0
</td>
<td>
alpha_1
</td>
<td>
alpha_2
</td>
</tr>
</table>
But you may have csv file with a different format.
Here we are going to show, how to convert your csv file format to the one required by navipy
...
...
This diff is collapsed.
Click to expand it.
tutorials/03-rendering-along-trajectory.ipynb
+
1
−
1
View file @
f781a3c6
...
@@ -162,7 +162,7 @@
...
@@ -162,7 +162,7 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.6.
5
"
"version": "3.6.
3
"
}
}
},
},
"nbformat": 4,
"nbformat": 4,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment