I remember that quite some time ago there was a posting to the mailing list ( in times before this forum existed) describing how to make movies from a NEURON simulation, unfortunately I don't remember the details. I would like to make a movie from a spaceplot. What i think is possible is to generate an eps file at every time step and then convert those and make the whole stack into a movie but I was wondering if there is an more elegant way.
Any suggestions or (even better) script examples would be very welcome.
How can we make movies from NEURON simulations?
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
The best tool I ever used was Gif-gIf-giF from Pedagoguery Software--makes capturing
animated gifs extremely easy. Only runs under MSWin, and it costs about US$30 but it
was one of the few MSWin programs that I really thought was well worth the money.
You can tell it to capture a window or a region or full screen, and you can have it capture
automatically on every screen update
http://www.peda.com/ggg/
UNIX/Linux/OS X users might find this article "Making Screen-Capture Movies" informative:
http://www.linuxdevcenter.com/pub/a/lin ... ovies.html
I have successfully used it. A possible refinement: instead of a shell script, use NEURON's
system() command, embedded in a custom run() procedure so that you automatically
capture a new frame after every fadvance().
You might also consider Alain Destexhe's method for making mpegs
http://cns.iaf.cnrs-gif.fr/alain_demos.html#mpeg
animated gifs extremely easy. Only runs under MSWin, and it costs about US$30 but it
was one of the few MSWin programs that I really thought was well worth the money.
You can tell it to capture a window or a region or full screen, and you can have it capture
automatically on every screen update
http://www.peda.com/ggg/
UNIX/Linux/OS X users might find this article "Making Screen-Capture Movies" informative:
http://www.linuxdevcenter.com/pub/a/lin ... ovies.html
I have successfully used it. A possible refinement: instead of a shell script, use NEURON's
system() command, embedded in a custom run() procedure so that you automatically
capture a new frame after every fadvance().
You might also consider Alain Destexhe's method for making mpegs
http://cns.iaf.cnrs-gif.fr/alain_demos.html#mpeg
http://www.vanelburg.net/neuronforum/Movie23.gif
http://www.vanelburg.net/neuronforum/VmMovie23.gif
Thanks Ted!
I combined elements of your second suggestion with elements of Destexhe's solution.
So first I created a function for plotting to eps:
where mySpacePlot is an object reference to a plot stored in a session file, where at the appropriate positrion I added
.
Now by overwriting it change the standard run system step procedure to:
Then under cygwin I used two bash scripts to convert the whole stack of eps files, first to a stack of gif files and then to a single gif-movie.
To make all of this work ImageMagick should be installed (I used the Q16 windows dll version) and ImageMagick needs ghostscript for conversion of eps to gif (Under XP AFPL ghostscript worked fine for me), but see Ted's second link. Also all the eps files should be numbered padded with zeros at the beginning to get them in the movie in the right order (i.e. still001.eps and still010.eps as opposed to still1.eps and still10.eps).
Depending on your configuration you might need to set the PATH variable in the bash shell script.
http://www.vanelburg.net/neuronforum/VmMovie23.gif
Thanks Ted!
I combined elements of your second suggestion with elements of Destexhe's solution.
So first I created a function for plotting to eps:
Code: Select all
stillno=0
objref mySpacePlot
func printspaceplot(){
sprint(epsfilename,"SpaceplotsEPS/still_%08d.eps",stillno)
stillno=stillno+1
mySpacePlot.printfile(epsfilename)
return 1
}
Code: Select all
mySpacePlot =save_window_
Now by overwriting it change the standard run system step procedure to:
Code: Select all
start_recording=0
stop_recording=tstop
proc step() {local i
if (using_cvode_) {
advance()
}else for i=1,nstep_steprun {
advance()
}
Plot()
// Added code is below
if(t >= start_recording && t < stop_recording){
printspaceplot()
}
}
Code: Select all
#!/bin/bash
OLDPATH=$PATH
echo $OLDPATH
PATH=$PATH:"/cygdrive/c/Program\ Files/ImageMagick-6.3.3-Q16":"C:\cygwin\bin"
# Convert all eps files in the directory to gif files
cd SpaceplotsEPS
../convertall.sh eps gif
cd ..
# Convert still*.gif files in the directory to a single gif movie
convert -delay 2 SpaceplotsEPS/still*.gif -loop 0 Movie/Movie01.gif
#For short movies you can print all individual pictures combined in a single picture
# montage Movie/Movie01.gif -coalesce Movie/coalesce_Movie01.gif
PATH=$OLDPATH
exit 0
Code: Select all
#!/bin/bash
# convertall.sh: convert file format
#
# convertall old_extension new_extension
#
# Example:
# To convert all *.gif files in working directory to *.jpg,
# convertall gif jpg
E_BADARGS=65
case $# in
0|1) # The vertical bar means "or" in this context.
echo "Usage: `basename $0` old_file_suffix new_file_suffix"
exit $E_BADARGS # If 0 or 1 arg, then bail out.
;;
esac
for filename in *.$1
# Traverse list of files ending with 1st argument.
do
echo convert: $filename ${filename%$1}$2
convert $filename ${filename%$1}$2
done
exit 0
Depending on your configuration you might need to set the PATH variable in the bash shell script.
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Excellent, Raj.
An alternative to modifying the standard run system:
use FInitializeHandler and the CVode class's event() method to periodically call the proc
that takes an individual snapshot. For hints, consider this example of a current pulse
generator:
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=163
An alternative to modifying the standard run system:
use FInitializeHandler and the CVode class's event() method to periodically call the proc
that takes an individual snapshot. For hints, consider this example of a current pulse
generator:
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=163